- All Superinterfaces:
ModuleChangeListener
- All Known Implementing Classes:
AbstractModulesRegistryImpl,ClassPathBasedModulesRegistry,ModulesRegistryImpl,SingleModulesRegistry,StaticModulesRegistry
- Author:
- Sanjeeb.Sahoo@Sun.COM
-
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.voidaddRepository(Repository repository) Add a newRepositoryto this registry.voidaddRepository(Repository repository, int weight) Add a newRepositoryto this registry.Creates a new childModulesRegistryin thisModulesRegistry.org.glassfish.hk2.api.ServiceLocatorCreates the defaultServiceLocatorfrom all the modules in this registry Calling this method has the same effect of calling {@link #createServiceLocator("default")}org.glassfish.hk2.api.ServiceLocatorcreateServiceLocator(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}.org.glassfish.hk2.api.ServiceLocatorcreateServiceLocator(org.glassfish.hk2.api.ServiceLocator serviceLocator, String name, List<org.glassfish.hk2.api.PopulatorPostProcessor> postProcessors) Creates aServiceLocatorwith the provided parent.voidDetaches all the modules from this registry.voiddumpState(PrintStream writer) Finds theHK2Modulethat 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 HK2Module containing at least one implementation of the passed service interface class.getProvidersClass(Class<T> serviceClass) getProvidingModule(String providerClassName) Gets theHK2Modulethat 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 HK2Module that has the package name in its list of exported interfaces.makeModuleFor(String name, String version) Returns theHK2Moduleinstance giving a name and version constraints.makeModuleFor(String name, String version, boolean resolve) Returns theHK2Moduleinstance giving a name and version constraints.org.glassfish.hk2.api.ServiceLocatorCreates an uninitializedServiceLocatororg.glassfish.hk2.api.ServiceLocatornewServiceLocator(org.glassfish.hk2.api.ServiceLocator parent) voidpopulateConfig(org.glassfish.hk2.api.ServiceLocator serviceLocator) voidpopulateServiceLocator(String name, org.glassfish.hk2.api.ServiceLocator h, List<org.glassfish.hk2.api.PopulatorPostProcessor> postProcessors) Populates aServiceLocatorfrom all the modules in this registry.voidPrint a Registry dump to the loggervoidregister(ModuleLifecycleListener listener) Add aModuleLifecycleListenerto this registry.<T> voidregisterRunningService(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(String name) Remove a repository from the list of attached repositories to this instances.voidsetParentClassLoader(ClassLoader parent) voidshutdown()Shuts down this module's registry, apply housekeeping tasksvoidunregister(ModuleLifecycleListener listener) Removes anModuleLifecycleListenerfrom this registry.<T> booleanunregisterRunningService(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 childModulesRegistryin thisModulesRegistry. -
newServiceLocator
org.glassfish.hk2.api.ServiceLocator newServiceLocator() throws org.glassfish.hk2.api.MultiExceptionCreates an uninitializedServiceLocator- Throws:
org.glassfish.hk2.api.MultiException
-
createServiceLocator
org.glassfish.hk2.api.ServiceLocator createServiceLocator() throws org.glassfish.hk2.api.MultiExceptionCreates 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:
org.glassfish.hk2.api.MultiException
-
createServiceLocator
org.glassfish.hk2.api.ServiceLocator createServiceLocator(String name) throws org.glassfish.hk2.api.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:
org.glassfish.hk2.api.MultiException
-
createServiceLocator
org.glassfish.hk2.api.ServiceLocator createServiceLocator(org.glassfish.hk2.api.ServiceLocator serviceLocator, String name, List<org.glassfish.hk2.api.PopulatorPostProcessor> postProcessors) Creates aServiceLocatorwith the provided parent.- Parameters:
serviceLocator-name-postProcessors-- Returns:
-
populateServiceLocator
void populateServiceLocator(String name, org.glassfish.hk2.api.ServiceLocator h, List<org.glassfish.hk2.api.PopulatorPostProcessor> postProcessors) throws org.glassfish.hk2.api.MultiException Populates 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:
org.glassfish.hk2.api.MultiException
-
addRepository
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
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
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
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 theHK2Moduleinstance 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 theHK2Moduleinstance 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 HK2Module that has the package name in its list of exported interfaces.- Parameters:
packageName- the requested implementation package name.- Returns:
- the
HK2Moduleinstance implementing the package name or null if not found. - Throws:
ResolveError- if the module dependencies cannot be resolved
-
getModules
Collection<HK2Module> 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
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
Registers a new DefaultModuleDefinition in this registry. Using this module definition, the registry will be capable of created shared and privateHK2Moduleinstances.- Throws:
ResolveError
-
add
Registers a new DefaultModuleDefinition in this registry. Using this module definition, the registry will be capable of created shared and privateHK2Moduleinstances.- 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 aModuleLifecycleListenerto this registry. The listener will be notified for each module startup and shutdown.- Parameters:
listener- the listener implementation
-
unregister
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
-
getProvidersClass
-
getModulesProvider
Returns a collection of HK2Module 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 theHK2Modulethat owns the given class.- Returns:
- null if the class is loaded outside the module system.
-
getProvidingModule
Gets theHK2Modulethat provides the provider of the given name. -
newServiceLocator
org.glassfish.hk2.api.ServiceLocator newServiceLocator(org.glassfish.hk2.api.ServiceLocator parent) throws org.glassfish.hk2.api.MultiException - Throws:
org.glassfish.hk2.api.MultiException
-
populateConfig
void populateConfig(org.glassfish.hk2.api.ServiceLocator serviceLocator) throws org.glassfish.hk2.api.MultiException - Throws:
org.glassfish.hk2.api.MultiException
-