Top Methods
com.sun.enterprise.module

public Interface ModulesRegistry

extends ModuleChangeListener
Known Direct Implementers
com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl
Annotations
@Contract
Imports
java.io.PrintStream, java.net.URL, java.util.Collection, .List, java.util.logging.Logger, org.glassfish.hk2.api.MultiException, .PopulatorPostProcessor, .ServiceLocator, org.jvnet.hk2.annotations.Contract

Author
[email protected]

Method Summary

Modifier and TypeMethod and Description
public HK2Module
add(ModuleDefinition info)

Registers a new DefaultModuleDefinition in this registry.

public HK2Module
add(ModuleDefinition
ModuleDefinition representing the new module content
info
,
boolean
should the new module be resolved or not
resolve
)

Registers a new DefaultModuleDefinition in this registry.

public void
addRepository(Repository
new repository to attach to this registry
repository
,
int
int value from 1 to 100 to specify the search order
weight
)

Add a new Repository to this registry.

public void
addRepository(Repository
new repository to attach to this registry
repository
)

Add a new Repository to this registry.

public ModulesRegistry
createChild()

Creates a new child ModulesRegistry in this ModulesRegistry.

public ServiceLocator
createServiceLocator()

Creates the default ServiceLocator from all the modules in this registry Calling this method has the same effect of calling createServiceLocator("default")

public ServiceLocator
createServiceLocator(String
Determines which inhabitants descriptors are loaded. (so that different parallel habitats can be created over the same modules registry.)
name
)

Creates a ServiceLocator from all the modules in this registry Cal;ling this method has the same effect of calling newServiceLocator() followed by org.glassfish.hk2.api.ServiceLocator, java.util.List.

public ServiceLocator
createServiceLocator(ServiceLocator serviceLocator, String name, List<PopulatorPostProcessor> postProcessors)

Creates a ServiceLocator with the provided parent.

public void
detachAll()

Detaches all the modules from this registry.

public void
public HK2Module

Returns:

null if the class is loaded outside the module system.
find
(Class<T> clazz)

Finds the HK2Module that owns the given class.

public Collection<HK2Module>

Returns:

an umodifiable list of loaded modules
getModules
()

Returns the list of shared Modules registered in this instance.

public Collection<HK2Module>

Returns:

an umodifiable list of loaded modules having names that match the given name
getModules
(String moduleName)

Returns the list of shared Modules registered in this instance whose name matches the given name

The returned list will not include the modules defined in the ancestor ModulesRegistrys.

public ClassLoader

Returns:

class loader instance
getModulesClassLoader
(ClassLoader
the parent class loader for the returned class loader instance
parent
,
Collection<ModuleDefinition>
module definitions for all modules this classloader should be capable of loading classes from
defs
)

Returns a ClassLoader capable of loading classes from a set of modules identified by their module definition

public ClassLoader

Returns:

class loader instance
getModulesClassLoader
(ClassLoader
the parent class loader for the returned class loader instance
parent
,
Collection<ModuleDefinition>
module definitions for all modules this classloader should be capable of loading
defs
,
URL[]
urls to be added to the module classloader
urls
)

Returns a ClassLoader capable of loading classes from a set of modules identified by their module definition and also load new urls.

public Iterable<HK2Module>

Returns:

a collection of module
getModulesProvider
(Class<T>
the service interface class
serviceClass
)

Returns a collection of HK2Module containing at least one implementation of the passed service interface class.

public ClassLoader
public <T> Iterable<Class<? extends T>>
getProvidersClass(Class<T> serviceClass)

public HK2Module
getProvidingModule(String providerClassName)

Gets the HK2Module that provides the provider of the given name.

public Repository

Returns:

the repository or null if not found
getRepository
(String
name of the repository to return
name
)

Get a repository from the list of attached repositories

public <T> List<T>

Returns:

the list of providers of that service.
getRunningServices
(Class<T>
the service interface
serviceClass
)

Returns all running services implementation of the passed service interface

public HK2Module

Returns:

the module instance or null if none can be found
makeModuleFor
(String
the module name
name
,
String
the module version. Caller should specify a correct version.
version
)

Returns the HK2Module instance giving a name and version constraints.

public HK2Module

Returns:

the module instance or null if none can be found
makeModuleFor
(String
the module name
name
,
String
the module version. Caller should specify a correct version.
version
,
boolean
should the module be resolved or not
resolve
)

Returns the HK2Module instance giving a name and version constraints.

public HK2Module

Returns:

the HK2Module instance implementing the package name or null if not found.
makeModuleFor
(String
the requested implementation package name.
packageName
)

Find and return a loaded HK2Module that has the package name in its list of exported interfaces.

public ServiceLocator
newServiceLocator()

Creates an uninitialized ServiceLocator

public ServiceLocator
public void
public void

Returns:

initialized Habitat
populateServiceLocator
(String
Determines which inhabitants descriptors are loaded. (so that different parallel habitats can be created over the same modules registry.)
name
,
ServiceLocator
Habitat to initialize, null if it should be created
h
,
List<PopulatorPostProcessor> postProcessors)

Populates a ServiceLocator from all the modules in this registry.

public void
register(ModuleLifecycleListener
the listener implementation
listener
)

Add a ModuleLifecycleListener to this registry.

public <T> void
registerRunningService(Class<T>
the service interface
serviceClass
,
T
the provider of that service.
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.

public void
removeRepository(String
name of the repository to remove
name
)

Remove a repository from the list of attached repositories to this instances.

public void
public void
shutdown()

Shuts down this module's registry, apply housekeeping tasks

public void
unregister(ModuleLifecycleListener
the listener to unregister
listener
)

Removes an ModuleLifecycleListener from this registry.

public <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.

Inherited from com.sun.enterprise.module.ModuleChangeListener:
changed

Method Detail

addback to summary
public HK2Module 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 private HK2Module instances.

addback to summary
public HK2Module 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 private HK2Module instances.

Parameters
info:ModuleDefinition

ModuleDefinition representing the new module content

resolve:boolean

should the new module be resolved or not

addRepositoryback to summary
public void addRepository(Repository repository, int weight)

Add a new Repository 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:Repository

new repository to attach to this registry

weight:int

int value from 1 to 100 to specify the search order

addRepositoryback to summary
public void addRepository(Repository repository)

Add a new Repository to this registry. From now on the repository will be used to procure requested nodule not registered in this instance.

Parameters
repository:Repository

new repository to attach to this registry

createChildback to summary
public ModulesRegistry createChild()

Creates a new child ModulesRegistry in this ModulesRegistry.

createServiceLocatorback to summary
public ServiceLocator createServiceLocator() throws MultiException

Creates the default ServiceLocator from all the modules in this registry Calling this method has the same effect of calling createServiceLocator("default")

createServiceLocatorback to summary
public ServiceLocator createServiceLocator(String name) throws MultiException

Creates a ServiceLocator from all the modules in this registry Cal;ling this method has the same effect of calling newServiceLocator() followed by org.glassfish.hk2.api.ServiceLocator, java.util.List.

Parameters
name:String

Determines which inhabitants descriptors are loaded. (so that different parallel habitats can be created over the same modules registry.)

createServiceLocatorback to summary
public ServiceLocator createServiceLocator(ServiceLocator serviceLocator, String name, List<PopulatorPostProcessor> postProcessors)

Creates a ServiceLocator with the provided parent.

detachAllback to summary
public void detachAll()

Detaches all the modules from this registry. The modules are not deconstructed when calling this method.

dumpStateback to summary
public void dumpState(PrintStream writer)
findback to summary
public HK2Module find(Class<T> clazz)

Finds the HK2Module that owns the given class.

Returns:HK2Module

null if the class is loaded outside the module system.

getModulesback to summary
public 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:Collection<HK2Module>

an umodifiable list of loaded modules

getModulesback to summary
public Collection<HK2Module> getModules(String moduleName)

Returns the list of shared Modules registered in this instance whose name matches the given name

The returned list will not include the modules defined in the ancestor ModulesRegistrys.

Returns:Collection<HK2Module>

an umodifiable list of loaded modules having names that match the given name

getModulesClassLoaderback to summary
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:ClassLoader

the parent class loader for the returned class loader instance

defs:Collection<ModuleDefinition>

module definitions for all modules this classloader should be capable of loading classes from

Returns:ClassLoader

class loader instance

Exceptions
ResolveError:
if one of the provided module definition cannot be resolved
getModulesClassLoaderback to summary
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:ClassLoader

the parent class loader for the returned class loader instance

defs:Collection<ModuleDefinition>

module definitions for all modules this classloader should be capable of loading

urls:URL[]

urls to be added to the module classloader

Returns:ClassLoader

class loader instance

Exceptions
ResolveError:
if one of the provided module definition cannot be resolved
getModulesProviderback to summary
public Iterable<HK2Module> getModulesProvider(Class<T> serviceClass)

Returns a collection of HK2Module containing at least one implementation of the passed service interface class.

Parameters
serviceClass:Class<T>

the service interface class

Returns:Iterable<HK2Module>

a collection of module

getParentClassLoaderback to summary
public ClassLoader getParentClassLoader()
getProvidersClassback to summary
public <T> Iterable<Class<? extends T>> getProvidersClass(Class<T> serviceClass)
getProvidingModuleback to summary
public HK2Module getProvidingModule(String providerClassName)

Gets the HK2Module that provides the provider of the given name.

getRepositoryback to summary
public Repository getRepository(String name)

Get a repository from the list of attached repositories

Parameters
name:String

name of the repository to return

Returns:Repository

the repository or null if not found

getRunningServicesback to summary
public <T> List<T> getRunningServices(Class<T> serviceClass)

Returns all running services implementation of the passed service interface

Parameters
serviceClass:Class<T>

the service interface

Returns:List<T>

the list of providers of that service.

makeModuleForback to summary
public HK2Module makeModuleFor(String name, String version) throws ResolveError

Returns the HK2Module instance giving a name and version constraints.

Parameters
name:String

the module name

version:String

the module version. Caller should specify a correct version.

Returns:HK2Module

the module instance or null if none can be found

Exceptions
ResolveError:
if the module dependencies cannot be resolved
makeModuleForback to summary
public HK2Module makeModuleFor(String name, String version, boolean resolve) throws ResolveError

Returns the HK2Module instance giving a name and version constraints.

Parameters
name:String

the module name

version:String

the module version. Caller should specify a correct version.

resolve:boolean

should the module be resolved or not

Returns:HK2Module

the module instance or null if none can be found

Exceptions
ResolveError:
if the module dependencies cannot be resolved
makeModuleForback to summary
public HK2Module makeModuleFor(String packageName) throws ResolveError

Find and return a loaded HK2Module that has the package name in its list of exported interfaces.

Parameters
packageName:String

the requested implementation package name.

Returns:HK2Module

the HK2Module instance implementing the package name or null if not found.

Exceptions
ResolveError:
if the module dependencies cannot be resolved
newServiceLocatorback to summary
public ServiceLocator newServiceLocator() throws MultiException

Creates an uninitialized ServiceLocator

newServiceLocatorback to summary
public ServiceLocator newServiceLocator(ServiceLocator parent) throws MultiException
populateConfigback to summary
public void populateConfig(ServiceLocator serviceLocator) throws MultiException
populateServiceLocatorback to summary
public void populateServiceLocator(String name, ServiceLocator h, List<PopulatorPostProcessor> postProcessors) throws MultiException

Populates a ServiceLocator from all the modules in this registry.

Default InhabitantsParser is used.

Parameters
name:String

Determines which inhabitants descriptors are loaded. (so that different parallel habitats can be created over the same modules registry.)

h:ServiceLocator

Habitat to initialize, null if it should be created

Returns:void

initialized Habitat

registerback to summary
public void register(ModuleLifecycleListener listener)

Add a ModuleLifecycleListener to this registry. The listener will be notified for each module startup and shutdown.

Parameters
listener:ModuleLifecycleListener

the listener implementation

registerRunningServiceback to summary
public <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.

Parameters
serviceClass:Class<T>

the service interface

provider:T

the provider of that service.

removeRepositoryback to summary
public void removeRepository(String name)

Remove a repository from the list of attached repositories to this instances. After this call, the Repository name will not be used to procure missing modules any longer

Parameters
name:String

name of the repository to remove

setParentClassLoaderback to summary
public void setParentClassLoader(ClassLoader parent)
shutdownback to summary
public void shutdown()

Shuts down this module's registry, apply housekeeping tasks

unregisterback to summary
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:ModuleLifecycleListener

the listener to unregister

unregisterRunningServiceback to summary
public <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.