Package com.sun.enterprise.module
Interface ModulesRegistry
-
- All Superinterfaces:
ModuleChangeListener
- All Known Implementing Classes:
AbstractModulesRegistryImpl,ClassPathBasedModulesRegistry,ModulesRegistryImpl,SingleModulesRegistry,StaticModulesRegistry
@Contract public interface ModulesRegistry extends ModuleChangeListener
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Moduleadd(ModuleDefinition info)Registers a new DefaultModuleDefinition in this registry.Moduleadd(ModuleDefinition info, boolean resolve)Registers a new DefaultModuleDefinition in this registry.voidaddRepository(Repository repository)Add a newRepositoryto this registry.voidaddRepository(Repository repository, int weight)Add a newRepositoryto this registry.ModulesRegistrycreateChild()Creates a new childModulesRegistryin thisModulesRegistry.ServiceLocatorcreateServiceLocator()Creates the defaultServiceLocatorfrom all the modules in this registry Calling this method has the same effect of calling {@link #createServiceLocator("default")}ServiceLocatorcreateServiceLocator(java.lang.String name)Creates aServiceLocatorfrom all the modules in this registry Cal;ling this method has the same effect of callingnewServiceLocator()followed by {@link #populateServiceLocator(String, org.glassfish.hk2.api.ServiceLocator, java.util.List}.ServiceLocatorcreateServiceLocator(ServiceLocator serviceLocator, java.lang.String name, java.util.List<PopulatorPostProcessor> postProcessors)Creates aServiceLocatorwith the provided parent.voiddetachAll()Detaches all the modules from this registry.voiddumpState(java.io.PrintStream writer)Modulefind(java.lang.Class clazz)Finds theModulethat owns the given class.java.util.Collection<Module>getModules()Returns the list of shared Modules registered in this instance.java.util.Collection<Module>getModules(java.lang.String moduleName)Returns the list of shared Modules registered in this instance whose name matches the given namejava.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.Iterable<Module>getModulesProvider(java.lang.Class serviceClass)Returns a collection of Module containing at least one implementation of the passed service interface class.java.lang.ClassLoadergetParentClassLoader()<T> java.lang.Iterable<java.lang.Class<? extends T>>getProvidersClass(java.lang.Class<T> serviceClass)ModulegetProvidingModule(java.lang.String providerClassName)Gets theModulethat provides the provider of the given name.RepositorygetRepository(java.lang.String name)Get a repository from the list of attached repositories<T> java.util.List<T>getRunningServices(java.lang.Class<T> serviceClass)Returns all running services implementation of the passed service interfaceModulemakeModuleFor(java.lang.String packageName)Find and return a loaded Module that has the package name in its list of exported interfaces.ModulemakeModuleFor(java.lang.String name, java.lang.String version)Returns theModuleinstance giving a name and version constraints.ModulemakeModuleFor(java.lang.String name, java.lang.String version, boolean resolve)Returns theModuleinstance giving a name and version constraints.ServiceLocatornewServiceLocator()Creates an uninitializedServiceLocatorServiceLocatornewServiceLocator(ServiceLocator parent)voidpopulateConfig(ServiceLocator serviceLocator)voidpopulateServiceLocator(java.lang.String name, ServiceLocator h, java.util.List<PopulatorPostProcessor> postProcessors)Populates aServiceLocatorfrom all the modules in this registry.voidprint(java.util.logging.Logger logger)Print a Registry dump to the loggervoidregister(ModuleLifecycleListener listener)Add aModuleLifecycleListenerto this registry.<T> voidregisterRunningService(java.lang.Class<T> serviceClass, T provider)Registers a running service, this is useful when other components need to have access to a provider of a service without having to create a new instance and initialize it.voidremoveRepository(java.lang.String name)Remove a repository from the list of attached repositories to this instances.voidsetParentClassLoader(java.lang.ClassLoader parent)voidshutdown()Shuts down this module's registry, apply housekeeping tasksvoidunregister(ModuleLifecycleListener listener)Removes anModuleLifecycleListenerfrom this registry.<T> booleanunregisterRunningService(java.lang.Class<T> serviceClass, T provider)Removes a running service, this is useful when a service instance is no longer available as a provider of a service.-
Methods inherited from interface com.sun.enterprise.module.ModuleChangeListener
changed
-
-
-
-
Method Detail
-
createChild
ModulesRegistry createChild()
Creates a new childModulesRegistryin thisModulesRegistry.
-
newServiceLocator
ServiceLocator newServiceLocator() throws MultiException
Creates an uninitializedServiceLocator- Throws:
MultiException
-
createServiceLocator
ServiceLocator createServiceLocator() throws MultiException
Creates the defaultServiceLocatorfrom all the modules in this registry Calling this method has the same effect of calling {@link #createServiceLocator("default")}- Parameters:
name- Determines which inhabitants descriptors are loaded. (so that different parallel habitats can be created over the same modules registry.)- Throws:
MultiException
-
createServiceLocator
ServiceLocator createServiceLocator(java.lang.String name) throws MultiException
Creates aServiceLocatorfrom all the modules in this registry Cal;ling this method has the same effect of callingnewServiceLocator()followed by {@link #populateServiceLocator(String, org.glassfish.hk2.api.ServiceLocator, java.util.List}.- Parameters:
name- Determines which inhabitants descriptors are loaded. (so that different parallel habitats can be created over the same modules registry.)- Throws:
MultiException
-
createServiceLocator
ServiceLocator createServiceLocator(ServiceLocator serviceLocator, java.lang.String name, java.util.List<PopulatorPostProcessor> postProcessors)
Creates aServiceLocatorwith the provided parent.- Parameters:
serviceLocator-name-postProcessors-- Returns:
-
populateServiceLocator
void populateServiceLocator(java.lang.String name, ServiceLocator h, java.util.List<PopulatorPostProcessor> postProcessors) throws MultiExceptionPopulates aServiceLocatorfrom all the modules in this registry.Default
InhabitantsParseris used.- Parameters:
name- Determines which inhabitants descriptors are loaded. (so that different parallel habitats can be created over the same modules registry.)h- Habitat to initialize, null if it should be createdpostProcessors-- Throws:
MultiException
-
addRepository
void addRepository(Repository repository, int weight)
Add a newRepositoryto this registry. From now on the repository will be used to procure requested module not yet registered in this registry instance. Repository can be searched in a particular order (to accomodate performance requirements like looking at local repositories first), a search order (1 to 100) can be specified when adding a repository to the registry (1 is highest priority).- Parameters:
repository- new repository to attach to this registryweight- int value from 1 to 100 to specify the search order
-
addRepository
void addRepository(Repository repository)
Add a newRepositoryto this registry. From now on the repository will be used to procure requested nodule not registered in this instance.- Parameters:
repository- new repository to attach to this registry
-
removeRepository
void removeRepository(java.lang.String name)
Remove a repository from the list of attached repositories to this instances. After this call, theRepositoryname will not be used to procure missing modules any longer- Parameters:
name- name of the repository to remove
-
getRepository
Repository getRepository(java.lang.String name)
Get a repository from the list of attached repositories- Parameters:
name- name of the repository to return- Returns:
- the repository or null if not found
-
makeModuleFor
Module makeModuleFor(java.lang.String name, java.lang.String version) throws ResolveError
Returns theModuleinstance giving a name and version constraints.- Parameters:
name- the module nameversion- the module version. Caller should specify a correct version.- Returns:
- the module instance or null if none can be found
- Throws:
ResolveError- if the module dependencies cannot be resolved
-
makeModuleFor
Module makeModuleFor(java.lang.String name, java.lang.String version, boolean resolve) throws ResolveError
Returns theModuleinstance giving a name and version constraints.- Parameters:
name- the module nameversion- the module version. Caller should specify a correct version.resolve- should the module be resolved or not- Returns:
- the module instance or null if none can be found
- Throws:
ResolveError- if the module dependencies cannot be resolved
-
makeModuleFor
Module makeModuleFor(java.lang.String packageName) throws ResolveError
Find and return a loaded Module that has the package name in its list of exported interfaces.- Parameters:
packageName- the requested implementation package name.- Returns:
- the
Moduleinstance implementing the package name or null if not found. - Throws:
ResolveError- if the module dependencies cannot be resolved
-
getModules
java.util.Collection<Module> getModules()
Returns the list of shared Modules registered in this instance.The returned list will not include the modules defined in the ancestor
ModulesRegistrys.- Returns:
- an umodifiable list of loaded modules
-
getModules
java.util.Collection<Module> getModules(java.lang.String moduleName)
Returns the list of shared Modules registered in this instance whose name matches the given nameThe returned list will not include the modules defined in the ancestor
ModulesRegistrys.- Returns:
- an umodifiable list of loaded modules having names that match the given name
-
detachAll
void detachAll()
Detaches all the modules from this registry. The modules are not deconstructed when calling this method.
-
add
Module add(ModuleDefinition info) throws ResolveError
Registers a new DefaultModuleDefinition in this registry. Using this module definition, the registry will be capable of created shared and privateModuleinstances.- Throws:
ResolveError
-
add
Module add(ModuleDefinition info, boolean resolve) throws ResolveError
Registers a new DefaultModuleDefinition in this registry. Using this module definition, the registry will be capable of created shared and privateModuleinstances.- Parameters:
info- ModuleDefinition representing the new module contentresolve- should the new module be resolved or not- Throws:
ResolveError
-
print
void print(java.util.logging.Logger logger)
Print a Registry dump to the logger- Parameters:
logger- the logger to dump on
-
register
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
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
-
shutdown
void shutdown()
Shuts down this module's registry, apply housekeeping tasks
-
dumpState
void dumpState(java.io.PrintStream writer)
-
getProvidersClass
<T> java.lang.Iterable<java.lang.Class<? extends T>> getProvidersClass(java.lang.Class<T> serviceClass)
-
getModulesProvider
java.lang.Iterable<Module> getModulesProvider(java.lang.Class serviceClass)
Returns a collection of Module containing at least one implementation of the passed service interface class.- Parameters:
serviceClass- the service interface class- Returns:
- a collection of module
-
registerRunningService
<T> void registerRunningService(java.lang.Class<T> serviceClass, T provider)Registers a running service, this is useful when other components need to have access to a provider of a service without having to create a new instance and initialize it.- Parameters:
serviceClass- the service interfaceprovider- the provider of that service.
-
unregisterRunningService
<T> boolean unregisterRunningService(java.lang.Class<T> serviceClass, T provider)Removes a running service, this is useful when a service instance is no longer available as a provider of a service.
-
getRunningServices
<T> java.util.List<T> getRunningServices(java.lang.Class<T> serviceClass)
Returns all running services implementation of the passed service interface- Parameters:
serviceClass- the service interface- Returns:
- the list of providers of that service.
-
setParentClassLoader
void setParentClassLoader(java.lang.ClassLoader parent)
-
getParentClassLoader
java.lang.ClassLoader getParentClassLoader()
-
getModulesClassLoader
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
-
getModulesClassLoader
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
-
find
Module find(java.lang.Class clazz)
Finds theModulethat owns the given class.- Returns:
- null if the class is loaded outside the module system.
-
getProvidingModule
Module getProvidingModule(java.lang.String providerClassName)
Gets theModulethat provides the provider of the given name.
-
newServiceLocator
ServiceLocator newServiceLocator(ServiceLocator parent) throws MultiException
- Throws:
MultiException
-
populateConfig
void populateConfig(ServiceLocator serviceLocator) throws MultiException
- Throws:
MultiException
-
-