com.sun.enterprise.module.impl
Class ModulesRegistryImpl

java.lang.Object
  extended by com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl
      extended by com.sun.enterprise.module.impl.ModulesRegistryImpl
All Implemented Interfaces:
ModuleChangeListener, ModulesRegistry, InhabitantsParserFactory
Direct Known Subclasses:
ClassPathBasedModulesRegistry, SingleModulesRegistry

public class ModulesRegistryImpl
extends AbstractModulesRegistryImpl

Author:
Jerome Dochez, Sanjeeb.Sahoo@Sun.COM

Field Summary
 
Fields inherited from class com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl
modules, parent, providers, repositories
 
Constructor Summary
ModulesRegistryImpl(AbstractModulesRegistryImpl parent)
           
 
Method Summary
 ModulesRegistry createChild()
          Creates a new child ModulesRegistryImpl in this ModulesRegistryImpl.
 void detachAll()
          Detaches all the modules from this registry.
 Module find(Class clazz)
          Finds the Module that owns the given class.
 List<ModuleLifecycleListener> getLifecycleListeners()
           
 ClassLoader getModulesClassLoader(ClassLoader parent, Collection<ModuleDefinition> defs)
          Returns a ClassLoader capable of loading classes from a set of modules identified by their module definition
 ClassLoader getModulesClassLoader(ClassLoader parent, Collection<ModuleDefinition> defs, URL[] urls)
          Returns a ClassLoader capable of loading classes from a set of modules identified by their module definition and also load new urls.
 ClassLoader getParentClassLoader()
          Returns the parent class loader parenting the class loaders created by modules associated with this registry.
 ModuleImpl getProvidingModule(String providerClassName)
          Gets the Module that provides the provider of the given name.
protected  Module newModule(ModuleDefinition moduleDef)
          Factory method for creating new instances of Module.
protected  void parseInhabitants(Module module, String name, ServiceLocator serviceLocator)
           
 void register(ModuleLifecycleListener listener)
          Add a ModuleLifecycleListener to this registry.
 void setParentClassLoader(ClassLoader parent)
          Sets the classloader parenting the class loaders created by the modules associated with this registry.
 void shutdown()
          Shuts down this module's registry, apply housekeeping tasks
 void unregister(ModuleLifecycleListener listener)
          Removes an ModuleLifecycleListener from this registry.
 
Methods inherited from class com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl
add, add, add, addRepository, addRepository, changed, createInhabitantsParser, createServiceLocator, dumpState, getModules, getModules, getModulesProvider, getProvidersClass, getRepository, getRunningServices, initializeServiceLocator, loadFromRepository, makeModuleFor, makeModuleFor, makeModuleFor, newServiceLocator, newServiceLocator, populateConfig, populateServiceLocator, print, registerRunningService, remove, removeRepository, unregisterRunningService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModulesRegistryImpl

public ModulesRegistryImpl(AbstractModulesRegistryImpl parent)
Method Detail

createChild

public ModulesRegistry createChild()
Creates a new child ModulesRegistryImpl in this ModulesRegistryImpl.


newModule

protected Module newModule(ModuleDefinition moduleDef)
Description copied from class: AbstractModulesRegistryImpl
Factory method for creating new instances of Module.

Specified by:
newModule in class AbstractModulesRegistryImpl
Parameters:
moduleDef - module definition of the new module to be created
Returns:
a new Module instance

parseInhabitants

protected void parseInhabitants(Module module,
                                String name,
                                ServiceLocator serviceLocator)
                         throws IOException
Specified by:
parseInhabitants in class AbstractModulesRegistryImpl
Throws:
IOException

getProvidingModule

public ModuleImpl getProvidingModule(String providerClassName)
Description copied from interface: ModulesRegistry
Gets the Module that provides the provider of the given name.

Specified by:
getProvidingModule in interface ModulesRegistry
Overrides:
getProvidingModule in class AbstractModulesRegistryImpl

setParentClassLoader

public void setParentClassLoader(ClassLoader parent)
Sets the classloader parenting the class loaders created by the modules associated with this registry.

Parameters:
parent - parent class loader

getParentClassLoader

public ClassLoader getParentClassLoader()
Returns the parent class loader parenting the class loaders created by modules associated with this registry.

Returns:
the parent classloader

getModulesClassLoader

public ClassLoader getModulesClassLoader(ClassLoader parent,
                                         Collection<ModuleDefinition> defs,
                                         URL[] urls)
                                  throws ResolveError
Returns a ClassLoader capable of loading classes from a set of modules identified by their module definition and also load new urls.

Parameters:
parent - the parent class loader for the returned class loader instance
defs - module definitions for all modules this classloader should be capable of loading
urls - urls to be added to the module classloader
Returns:
class loader instance
Throws:
ResolveError - if one of the provided module definition cannot be resolved

getModulesClassLoader

public ClassLoader getModulesClassLoader(ClassLoader parent,
                                         Collection<ModuleDefinition> defs)
                                  throws ResolveError
Returns a ClassLoader capable of loading classes from a set of modules identified by their module definition

Parameters:
parent - the parent class loader for the returned class loader instance
defs - module definitions for all modules this classloader should be capable of loading classes from
Returns:
class loader instance
Throws:
ResolveError - if one of the provided module definition cannot be resolved

find

public Module find(Class clazz)
Description copied from interface: ModulesRegistry
Finds the Module that owns the given class.

Returns:
null if the class is loaded outside the module system.

register

public void register(ModuleLifecycleListener listener)
Add a ModuleLifecycleListener to this registry. The listener will be notified for each module startup and shutdown.

Parameters:
listener - the listener implementation

unregister

public void unregister(ModuleLifecycleListener listener)
Removes an ModuleLifecycleListener from this registry. Notification of module startup and shutdown will not be emitted to this listener any longer.

Parameters:
listener - the listener to unregister

getLifecycleListeners

public List<ModuleLifecycleListener> getLifecycleListeners()

detachAll

public void detachAll()
Detaches all the modules from this registry. The modules are not deconstructed when calling this method.


shutdown

public void shutdown()
Shuts down this module's registry, apply housekeeping tasks



Copyright © 2013 Oracle Corporation. All Rights Reserved.