org.abstracthorizon.extend.server.deployment
Class DeploymentManagerImpl

java.lang.Object
  extended by org.abstracthorizon.extend.server.deployment.DeploymentManagerImpl
All Implemented Interfaces:
DeploymentManager, ModuleLoader

public class DeploymentManagerImpl
extends Object
implements DeploymentManager

Implementation of DeploymentManager.

Author:
Daniel Sendula

Nested Class Summary
protected  class DeploymentManagerImpl.DeployedModules<KeyType,ValueType>
          This class keeps deployed modules.
protected  class DeploymentManagerImpl.ModuleLoaders<E>
          This class is extension of LinkedHashSet that on adding new element calls tryToDeployUnknown() method.
 
Field Summary
protected  DeploymentManagerImpl.DeployedModules<ModuleId,Module> deployedModules
          Map of deployed modules
protected  DeploymentManagerImpl.ModuleLoaders<ModuleLoader> moduleLoaders
          List of module loaders
 
Fields inherited from interface org.abstracthorizon.extend.server.deployment.DeploymentManager
DEPLOYMENT_MANAGER_DEFAULT_NAME
 
Constructor Summary
DeploymentManagerImpl()
          Empty constructor
 
Method Summary
 boolean canLoad(URI url)
          Returns true if any of registered module loaders knows how to load (create) module from given url.
 void create(Module module)
          Calls Module.create() method.
 void deploy(ModuleId moduleId, Module module)
          Deploys given module.
 void destroy(Module module)
          Calls Module.destroy() method.
 Set<ModuleId> findAliases(Module module)
          Returns all aliases module is known under
 EnhancedMap<ModuleId,Module> getDeployedModules()
          Returns map of deployed modules.
 Set<ModuleLoader> getModuleLoaders()
          Returns set of module loaders
protected static String getUnsatisfiedDependenciesAsAList(Module module)
           
 boolean isDeployed(Module module)
          Checks if module is deployed.
 Module load(URI uri)
          Loads module from given URI.
 Module loadAndDeploy(URI uri)
          Utility method that loads and deploys module in one go.
 Module loadAs(URI uri, ModuleId moduleId)
          Loads module from given URI.
 void redeploy(Module module)
          Re-deploys given module.
 void redeploy(ModuleId moduleId)
          Utility method
 void setModuleLoaders(Set<ModuleLoader> moduleLoaders)
          Sets module loaders.
 void start(Module module)
          Calls Module.start() method.
 void stop(Module module)
          Calls Module.stop() method.
 ModuleId toModuleId(URI uri)
          Translates URI to moduleId
protected  void tryToDeployUnknown()
          This method goes through all modules with unknown loaders and tries to load them again (using all registered module loaders)
 void undeploy(Module module)
          Undeploys given module.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

moduleLoaders

protected DeploymentManagerImpl.ModuleLoaders<ModuleLoader> moduleLoaders
List of module loaders


deployedModules

protected DeploymentManagerImpl.DeployedModules<ModuleId,Module> deployedModules
Map of deployed modules

Constructor Detail

DeploymentManagerImpl

public DeploymentManagerImpl()
Empty constructor

Method Detail

isDeployed

public boolean isDeployed(Module module)
Checks if module is deployed.

Parameters:
module - module
Returns:
true if given module is deployed

deploy

public void deploy(ModuleId moduleId,
                   Module module)
Deploys given module. It calls Module.create() and Module.start() methods.

Specified by:
deploy in interface DeploymentManager
Parameters:
module - module
Throws:
RuntimeException - if module with the same name is already deployed (and is not ProvisionalModule

undeploy

public void undeploy(Module module)
Undeploys given module. It calls Module.stop() and Module.destroy() methods.

Specified by:
undeploy in interface DeploymentManager
Parameters:
module - module

redeploy

public void redeploy(Module module)
Re-deploys given module. Effectively it calls undeploy(Module) and #deploy(Module) methods.

Specified by:
redeploy in interface DeploymentManager
Parameters:
module - module

findAliases

public Set<ModuleId> findAliases(Module module)
Returns all aliases module is known under

Parameters:
module - module
Returns:
set of aliases

create

public void create(Module module)
Calls Module.create() method.

Specified by:
create in interface DeploymentManager
Parameters:
module - module whose create method is to be called

start

public void start(Module module)
Calls Module.start() method.

Specified by:
start in interface DeploymentManager
Parameters:
module - module whose start method is to be called

stop

public void stop(Module module)
Calls Module.stop() method.

Specified by:
stop in interface DeploymentManager
Parameters:
module - module whose stop method is to be called

destroy

public void destroy(Module module)
Calls Module.destroy() method.

Specified by:
destroy in interface DeploymentManager
Parameters:
module - module whose destroy method is to be called

getDeployedModules

public EnhancedMap<ModuleId,Module> getDeployedModules()
Returns map of deployed modules.

Specified by:
getDeployedModules in interface DeploymentManager
Returns:
map of deployed modules

canLoad

public boolean canLoad(URI url)
Returns true if any of registered module loaders knows how to load (create) module from given url.

Specified by:
canLoad in interface ModuleLoader
Parameters:
url - url
Returns:
true if module knows how to load (create) module from given url

toModuleId

public ModuleId toModuleId(URI uri)
Translates URI to moduleId

Specified by:
toModuleId in interface ModuleLoader
Parameters:
uri - uri
Returns:
module id or null

load

public Module load(URI uri)
Loads module from given URI. If none of registered module loaders can load the module new ProvisionalModule is created with the name of last part of the URI. will return null.

Specified by:
load in interface ModuleLoader
Parameters:
uri - URI for module to be loaded from
Returns:
module from given URI

loadAs

public Module loadAs(URI uri,
                     ModuleId moduleId)
Loads module from given URI. If none of registered module loaders can load the module new ProvisionalModule is created with the name of last part of the URI. will return null.

Specified by:
loadAs in interface ModuleLoader
Parameters:
uri - URI for module to be loaded from
moduleId - module id to be used in final module
Returns:
module from given URI

loadAndDeploy

public Module loadAndDeploy(URI uri)
Utility method that loads and deploys module in one go.

Specified by:
loadAndDeploy in interface DeploymentManager
Parameters:
uri - module's URI
Returns:
loaded module or null if module cannot be loaded TODO check return statement

redeploy

public void redeploy(ModuleId moduleId)
Utility method

Parameters:
uri - URI

getModuleLoaders

public Set<ModuleLoader> getModuleLoaders()
Returns set of module loaders

Specified by:
getModuleLoaders in interface DeploymentManager
Returns:
module loaders

setModuleLoaders

public void setModuleLoaders(Set<ModuleLoader> moduleLoaders)
Sets module loaders. Given set is copied into internal representation that is previously cleared down.

Specified by:
setModuleLoaders in interface DeploymentManager
Parameters:
moduleLoaders - module loaders

tryToDeployUnknown

protected void tryToDeployUnknown()
This method goes through all modules with unknown loaders and tries to load them again (using all registered module loaders)


getUnsatisfiedDependenciesAsAList

protected static String getUnsatisfiedDependenciesAsAList(Module module)


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