org.abstracthorizon.extend.support.spring.service
Class ServiceModuleLoader

java.lang.Object
  extended by org.abstracthorizon.extend.server.deployment.service.AbstractServiceModuleLoader
      extended by org.abstracthorizon.extend.support.spring.service.SpringAbstractServiceModuleLoader
          extended by org.abstracthorizon.extend.support.spring.service.ServiceModuleLoader
All Implemented Interfaces:
ModuleLoader, ApplicationContextAware
Direct Known Subclasses:
DanubeWarModuleLoader, JettyWarModuleLoader, TomcatWarModuleLoader

public class ServiceModuleLoader
extends SpringAbstractServiceModuleLoader

Service module loader. It loads "service.xml" file as spring's application context xml configuration file. TODO: explain donwloading and unpacking of archives

Author:
Daniel Sendula

Field Summary
protected  int bufferSize
          Buffer for downlaod size
static int INITIAL_BUFFER_SIZE
          Initial buffer size
protected  RedeployURLScanner redeployURLScanner
          Redeployment URL scanner
 
Fields inherited from class org.abstracthorizon.extend.support.spring.service.SpringAbstractServiceModuleLoader
root
 
Fields inherited from class org.abstracthorizon.extend.server.deployment.service.AbstractServiceModuleLoader
deploymentManager, extensions
 
Constructor Summary
ServiceModuleLoader()
          Empty constructor
 
Method Summary
protected  void addFilesForScanning(AbstractApplicationContextModule module)
          Hook method that collects all important files from newly created module and adds then to the URL redeployment scanner.
protected  void copy(InputStream is, OutputStream os)
           
protected  AbstractApplicationContextModule createModule(URL url)
          Creates new module that is extension of AbstractApplicationContextModule
protected  void downloadArchive(URL url, File file)
          Downloads the archive
 int getBufferSize()
          Returns buffer size for downloading
 RedeployURLScanner getRedeployURLScanner()
          Returns redeploy URL scanner
 Module load(URI uri)
          Creates ServiceApplicationContextModule and initialises it.
 Module loadAs(URI uri, ModuleId moduleId)
          Creates ServiceApplicationContextModule and initialises it.
protected  void postDefinitionProcessing(AbstractApplicationContextModule service)
          Called after module is defined
protected  void preDefinitionProcessing(AbstractApplicationContextModule service)
          Called before module is pronounced defined
 void setBufferSize(int bufferSize)
          Sets buffer size for downloading
 void setRedeployURLScanner(RedeployURLScanner redeployURLScanner)
          Sets redeploy URL scanner
 ModuleId toModuleId(URI uri)
          Translates URI to moduleId
protected  void unpackArchive(File from, File to)
          Unpacks the archive to run
 
Methods inherited from class org.abstracthorizon.extend.support.spring.service.SpringAbstractServiceModuleLoader
canLoad, setApplicationContext, start
 
Methods inherited from class org.abstracthorizon.extend.server.deployment.service.AbstractServiceModuleLoader
getDeploymentManager, getExtensions, setDeploymentManager, setExtensions, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_BUFFER_SIZE

public static final int INITIAL_BUFFER_SIZE
Initial buffer size

See Also:
Constant Field Values

bufferSize

protected int bufferSize
Buffer for downlaod size


redeployURLScanner

protected RedeployURLScanner redeployURLScanner
Redeployment URL scanner

Constructor Detail

ServiceModuleLoader

public ServiceModuleLoader()
Empty constructor

Method Detail

toModuleId

public ModuleId toModuleId(URI uri)
Translates URI to moduleId

Parameters:
uri - uri
Returns:
module id or null

load

public Module load(URI uri)
Creates ServiceApplicationContextModule and initialises it.

This implementation checks if file or directory is supplied as URI (directory has distinct "/" at the end of the file path). If it is directory then it has to be on filesystem - url with "file" protocol. If it is a file then it is assimed to be jar file. If file is remote file (url's protocol is not "file") then file is firstly downloaded.

Parameters:
uri - url for module to be loaded from
Returns:
module initialised ServiceApplicationContextModule

loadAs

public Module loadAs(URI uri,
                     ModuleId moduleId)
Creates ServiceApplicationContextModule and initialises it.

This implementation checks if file or directory is supplied as URI (directory has distinct "/" at the end of the file path). If it is directory then it has to be on filesystem - url with "file" protocol. If it is a file then it is assimed to be jar file. If file is remote file (url's protocol is not "file") then file is firstly downloaded.

Parameters:
uri - url for module to be loaded from
moduleId - module id
Returns:
module initialised ServiceApplicationContextModule

createModule

protected AbstractApplicationContextModule createModule(URL url)
Creates new module that is extension of AbstractApplicationContextModule

Parameters:
url - url for the module
Returns:
newly created module

preDefinitionProcessing

protected void preDefinitionProcessing(AbstractApplicationContextModule service)
Called before module is pronounced defined

Parameters:
service - service

postDefinitionProcessing

protected void postDefinitionProcessing(AbstractApplicationContextModule service)
Called after module is defined

Parameters:
service - service

addFilesForScanning

protected void addFilesForScanning(AbstractApplicationContextModule module)
Hook method that collects all important files from newly created module and adds then to the URL redeployment scanner.


getRedeployURLScanner

public RedeployURLScanner getRedeployURLScanner()
Returns redeploy URL scanner

Returns:
redeploy URL scanner

setRedeployURLScanner

public void setRedeployURLScanner(RedeployURLScanner redeployURLScanner)
Sets redeploy URL scanner

Parameters:
redeployURLScanner - redeploy URL scanner

downloadArchive

protected void downloadArchive(URL url,
                               File file)
Downloads the archive

Parameters:
url - url to download archive from
file - result file

unpackArchive

protected void unpackArchive(File from,
                             File to)
Unpacks the archive to run

Parameters:
from - archive file
to - result directory

getBufferSize

public int getBufferSize()
Returns buffer size for downloading

Returns:
buffer size for downloading

setBufferSize

public void setBufferSize(int bufferSize)
Sets buffer size for downloading

Parameters:
bufferSize - buffer size for downloading

copy

protected void copy(InputStream is,
                    OutputStream os)
             throws IOException
Throws:
IOException


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.