Package com.sun.enterprise.module
Interface ModulesRegistry
- All Superinterfaces:
ModuleChangeListener
- All Known Implementing Classes:
AbstractModulesRegistryImpl
,ClassPathBasedModulesRegistry
,ModulesRegistryImpl
,SingleModulesRegistry
,StaticModulesRegistry
-
Method Summary
Modifier and TypeMethodDescriptionadd
(ModuleDefinition info) Registers a new DefaultModuleDefinition in this registry.add
(ModuleDefinition info, boolean resolve) Registers a new DefaultModuleDefinition in this registry.void
addRepository
(Repository repository) Add a newRepository
to this registry.void
addRepository
(Repository repository, int weight) Add a newRepository
to this registry.Creates a new childModulesRegistry
in thisModulesRegistry
.Creates the defaultServiceLocator
from all the modules in this registry Calling this method has the same effect of callinginvalid @link
{@link #createServiceLocator("default")
createServiceLocator
(String name) Creates aServiceLocator
from all the modules in this registry Cal;ling this method has the same effect of callingnewServiceLocator()
followed byinvalid @link
{@link #populateServiceLocator(String, org.glassfish.hk2.api.ServiceLocator, java.util.List
createServiceLocator
(ServiceLocator serviceLocator, String name, List<PopulatorPostProcessor> postProcessors) Creates aServiceLocator
with the provided parent.void
Detaches all the modules from this registry.void
dumpState
(PrintStream writer) Finds theModule
that owns the given class.Returns the list of shared Modules registered in this instance.getModules
(String moduleName) Returns the list of shared Modules registered in this instance whose name matches the given namegetModulesClassLoader
(ClassLoader parent, Collection<ModuleDefinition> defs) Returns a ClassLoader capable of loading classes from a set of modules identified by their module definitiongetModulesClassLoader
(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.getModulesProvider
(Class serviceClass) Returns a collection of Module containing at least one implementation of the passed service interface class.getProvidersClass
(Class<T> serviceClass) getProvidingModule
(String providerClassName) Gets theModule
that provides the provider of the given name.getRepository
(String name) Get a repository from the list of attached repositories<T> List
<T> getRunningServices
(Class<T> serviceClass) Returns all running services implementation of the passed service interfacemakeModuleFor
(String packageName) Find and return a loaded Module that has the package name in its list of exported interfaces.makeModuleFor
(String name, String version) Returns theModule
instance giving a name and version constraints.makeModuleFor
(String name, String version, boolean resolve) Returns theModule
instance giving a name and version constraints.Creates an uninitializedServiceLocator
newServiceLocator
(ServiceLocator parent) void
populateConfig
(ServiceLocator serviceLocator) void
populateServiceLocator
(String name, ServiceLocator h, List<PopulatorPostProcessor> postProcessors) Populates aServiceLocator
from all the modules in this registry.void
Print a Registry dump to the loggervoid
register
(ModuleLifecycleListener listener) Add aModuleLifecycleListener
to this registry.<T> void
registerRunningService
(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.void
removeRepository
(String name) Remove a repository from the list of attached repositories to this instances.void
setParentClassLoader
(ClassLoader parent) void
shutdown()
Shuts down this module's registry, apply housekeeping tasksvoid
unregister
(ModuleLifecycleListener listener) Removes anModuleLifecycleListener
from this registry.<T> boolean
unregisterRunningService
(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 Details
-
createChild
ModulesRegistry createChild()Creates a new childModulesRegistry
in thisModulesRegistry
. -
newServiceLocator
Creates an uninitializedServiceLocator
- Throws:
MultiException
-
createServiceLocator
Creates the defaultServiceLocator
from all the modules in this registry Calling this method has the same effect of callinginvalid @link
{@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
Creates aServiceLocator
from all the modules in this registry Cal;ling this method has the same effect of callingnewServiceLocator()
followed byinvalid @link
{@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, String name, List<PopulatorPostProcessor> postProcessors) Creates aServiceLocator
with the provided parent.- Parameters:
serviceLocator
-name
-postProcessors
-- Returns:
-
populateServiceLocator
void populateServiceLocator(String name, ServiceLocator h, List<PopulatorPostProcessor> postProcessors) throws MultiException Populates aServiceLocator
from all the modules in this registry.Default
invalid reference
InhabitantsParser
- 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
Add a newRepository
to 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
Add a newRepository
to 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
Remove a repository from the list of attached repositories to this instances. After this call, theRepository
name will not be used to procure missing modules any longer- Parameters:
name
- name of the repository to remove
-
getRepository
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
Returns theModule
instance 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
Returns theModule
instance 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
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
Module
instance implementing the package name or null if not found. - Throws:
ResolveError
- if the module dependencies cannot be resolved
-
getModules
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
ModulesRegistry
s.- Returns:
- an umodifiable list of loaded modules
-
getModules
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
ModulesRegistry
s.- 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
Registers a new DefaultModuleDefinition in this registry. Using this module definition, the registry will be capable of created shared and privateModule
instances.- Throws:
ResolveError
-
add
Registers a new DefaultModuleDefinition in this registry. Using this module definition, the registry will be capable of created shared and privateModule
instances.- Parameters:
info
- ModuleDefinition representing the new module contentresolve
- should the new module be resolved or not- Throws:
ResolveError
-
print
Print a Registry dump to the logger- Parameters:
logger
- the logger to dump on
-
register
Add aModuleLifecycleListener
to this registry. The listener will be notified for each module startup and shutdown.- Parameters:
listener
- the listener implementation
-
unregister
Removes anModuleLifecycleListener
from 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
-
getProvidersClass
-
getModulesProvider
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
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
Removes a running service, this is useful when a service instance is no longer available as a provider of a service. -
getRunningServices
Returns all running services implementation of the passed service interface- Parameters:
serviceClass
- the service interface- Returns:
- the list of providers of that service.
-
setParentClassLoader
-
getParentClassLoader
ClassLoader getParentClassLoader() -
getModulesClassLoader
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 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
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 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
Finds theModule
that owns the given class.- Returns:
- null if the class is loaded outside the module system.
-
getProvidingModule
Gets theModule
that provides the provider of the given name. -
newServiceLocator
- Throws:
MultiException
-
populateConfig
- Throws:
MultiException
-