Package com.sun.enterprise.module.impl
Class ModulesRegistryImpl
- java.lang.Object
-
- com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl
-
- com.sun.enterprise.module.impl.ModulesRegistryImpl
-
- All Implemented Interfaces:
ModuleChangeListener,ModulesRegistry
- Direct Known Subclasses:
ClassPathBasedModulesRegistry,SingleModulesRegistry
public class ModulesRegistryImpl extends AbstractModulesRegistryImpl
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.List<ModuleLifecycleListener>lifecycleListenersprivate java.lang.ClassLoaderparentLoader-
Fields inherited from class com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl
modules, parent, providers, repositories
-
-
Constructor Summary
Constructors Constructor Description ModulesRegistryImpl(ModulesRegistry parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ModulesRegistrycreateChild()Creates a new childModulesRegistryImplin thisModulesRegistryImpl.voiddetachAll()Detaches all the modules from this registry.Modulefind(java.lang.Class clazz)Finds theModulethat owns the given class.java.util.List<ModuleLifecycleListener>getLifecycleListeners()java.lang.ClassLoadergetModulesClassLoader(java.lang.ClassLoader parent, java.util.Collection<ModuleDefinition> defs)Returns a ClassLoader capable of loading classes from a set of modules identified by their module definitionjava.lang.ClassLoadergetModulesClassLoader(java.lang.ClassLoader parent, java.util.Collection<ModuleDefinition> defs, java.net.URL[] urls)Returns a ClassLoader capable of loading classes from a set of modules identified by their module definition and also load new urls.java.lang.ClassLoadergetParentClassLoader()Returns the parent class loader parenting the class loaders created by modules associated with this registry.ModuleImplgetProvidingModule(java.lang.String providerClassName)Gets theModulethat provides the provider of the given name.protected ModulenewModule(ModuleDefinition moduleDef)Factory method for creating new instances of Module.(package private) ModuleImplnewPrivateModuleFor(java.lang.String moduleName, java.lang.String version)Creates and return a new private module implementation giving a name and version constraints.protected java.util.List<ActiveDescriptor>parseInhabitants(Module module, java.lang.String name, ServiceLocator serviceLocator, java.util.List<PopulatorPostProcessor> postProcessors)voidregister(ModuleLifecycleListener listener)Add aModuleLifecycleListenerto this registry.voidsetParentClassLoader(java.lang.ClassLoader parent)Sets the classloader parenting the class loaders created by the modules associated with this registry.voidshutdown()Shuts down this module's registry, apply housekeeping tasksvoidunregister(ModuleLifecycleListener listener)Removes anModuleLifecycleListenerfrom this registry.-
Methods inherited from class com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl
add, add, add, addRepository, addRepository, changed, createServiceLocator, createServiceLocator, createServiceLocator, dumpState, getAllServiceLocators, getModules, getModules, getModulesProvider, getProvidersClass, getRepository, getRunningServices, initializeServiceLocator, loadFromRepository, makeModuleFor, makeModuleFor, makeModuleFor, newServiceLocator, newServiceLocator, populateConfig, populateServiceLocator, print, registerRunningService, remove, removeRepository, unregisterRunningService
-
-
-
-
Field Detail
-
parentLoader
private java.lang.ClassLoader parentLoader
-
lifecycleListeners
final java.util.List<ModuleLifecycleListener> lifecycleListeners
-
-
Constructor Detail
-
ModulesRegistryImpl
public ModulesRegistryImpl(ModulesRegistry parent)
-
-
Method Detail
-
createChild
public ModulesRegistry createChild()
Creates a new childModulesRegistryImplin thisModulesRegistryImpl.
-
newModule
protected Module newModule(ModuleDefinition moduleDef)
Description copied from class:AbstractModulesRegistryImplFactory method for creating new instances of Module.- Specified by:
newModulein classAbstractModulesRegistryImpl- Parameters:
moduleDef- module definition of the new module to be created- Returns:
- a new Module instance
-
parseInhabitants
protected java.util.List<ActiveDescriptor> parseInhabitants(Module module, java.lang.String name, ServiceLocator serviceLocator, java.util.List<PopulatorPostProcessor> postProcessors) throws java.io.IOException
- Specified by:
parseInhabitantsin classAbstractModulesRegistryImpl- Throws:
java.io.IOException
-
newPrivateModuleFor
ModuleImpl newPrivateModuleFor(java.lang.String moduleName, java.lang.String version)
Creates and return a new private module implementation giving a name and version constraints. A private module is like any other module except it is not registered to be shared by other potential module users.- Parameters:
moduleName- the module nameversion- the desired version- Returns:
- the new private module or null if cannot be found
- Throws:
ResolveError- if the module dependencies cannot be resolved
-
getProvidingModule
public ModuleImpl getProvidingModule(java.lang.String providerClassName)
Description copied from interface:ModulesRegistryGets theModulethat provides the provider of the given name.- Specified by:
getProvidingModulein interfaceModulesRegistry- Overrides:
getProvidingModulein classAbstractModulesRegistryImpl
-
setParentClassLoader
public void setParentClassLoader(java.lang.ClassLoader parent)
Sets the classloader parenting the class loaders created by the modules associated with this registry.- Parameters:
parent- parent class loader
-
getParentClassLoader
public java.lang.ClassLoader getParentClassLoader()
Returns the parent class loader parenting the class loaders created by modules associated with this registry.- Returns:
- the parent classloader
-
getModulesClassLoader
public java.lang.ClassLoader getModulesClassLoader(java.lang.ClassLoader parent, java.util.Collection<ModuleDefinition> defs, java.net.URL[] urls) throws ResolveErrorReturns 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 instancedefs- module definitions for all modules this classloader should be capable of loadingurls- 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 java.lang.ClassLoader getModulesClassLoader(java.lang.ClassLoader parent, java.util.Collection<ModuleDefinition> defs) throws ResolveErrorReturns 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 instancedefs- 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(java.lang.Class clazz)
Description copied from interface:ModulesRegistryFinds theModulethat owns the given class.- Returns:
- null if the class is loaded outside the module system.
-
register
public void register(ModuleLifecycleListener listener)
Add aModuleLifecycleListenerto 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 anModuleLifecycleListenerfrom 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 java.util.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
-
-