|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl
public abstract class AbstractModulesRegistryImpl
The Modules Registry maintains the registry of all available module. TODO: concurrency bug in the acess of the repositories field.
Field Summary | |
---|---|
protected ConcurrentMap<ModuleId,Module> |
modules
|
protected AbstractModulesRegistryImpl |
parent
ModulesRegistry can form a tree structure by using this pointer. |
protected Map<String,Module> |
providers
Service provider class names and which modules they are in. |
protected Map<Integer,Repository> |
repositories
|
Constructor Summary | |
---|---|
protected |
AbstractModulesRegistryImpl(AbstractModulesRegistryImpl parent)
|
Method Summary | ||
---|---|---|
protected void |
add(Module newModule)
Add a new module to this registry. |
|
Module |
add(ModuleDefinition info)
Registers a new DefaultModuleDefinition in this registry. |
|
Module |
add(ModuleDefinition info,
boolean resolve)
Registers a new DefaultModuleDefinition in this registry. |
|
void |
addRepository(Repository repository)
Add a new Repository to this registry. |
|
void |
addRepository(Repository repository,
int weight)
Add a new Repository to this registry. |
|
void |
changed(Module service)
Modules can notify their registry that they have changed (classes, resources,etc...). |
|
InhabitantsParser |
createInhabitantsParser(ServiceLocator h)
|
|
ServiceLocator |
createServiceLocator(String name)
Creates a ServiceLocator from all the modules in this registry
Cal;ling this method has the same effect of calling ModulesRegistry.newServiceLocator() followed by
ModulesRegistry.populateServiceLocator(String, ServiceLocator) . |
|
void |
dumpState(PrintStream writer)
|
|
Collection<Module> |
getModules()
Returns the list of shared Modules registered in this instance. |
|
Collection<Module> |
getModules(String moduleName)
Returns the list of shared Modules registered in this instance whose name matches the given name |
|
Iterable<Module> |
getModulesProvider(Class serviceClass)
Returns a collection of Module containing at least one implementation of the passed service interface class. |
|
|
getProvidersClass(Class<T> serviceClass)
|
|
Module |
getProvidingModule(String providerClassName)
Gets the Module that provides the provider of the given name. |
|
Repository |
getRepository(String name)
Get a repository from the list of attached repositories |
|
|
getRunningServices(Class<T> serviceClass)
Returns all running services implementation of the passed service interface |
|
protected void |
initializeServiceLocator(ServiceLocator serviceLocator)
|
|
protected Module |
loadFromRepository(String name,
String version)
|
|
Module |
makeModuleFor(String packageName)
Find and return a loaded Module that has the package name in its list of exported interfaces. |
|
Module |
makeModuleFor(String name,
String version)
Returns the Module instance giving a name and version
constraints. |
|
Module |
makeModuleFor(String name,
String version,
boolean resolve)
Returns the Module instance giving a name and version
constraints. |
|
protected abstract Module |
newModule(ModuleDefinition moduleDef)
Factory method for creating new instances of Module. |
|
ServiceLocator |
newServiceLocator()
Creates an uninitialized Habitat |
|
ServiceLocator |
newServiceLocator(ServiceLocator parent,
String name)
Create a new Habitat optionally providing a parent Services as well as a name. |
|
protected abstract void |
parseInhabitants(Module module,
String name,
ServiceLocator serviceLocator)
|
|
protected void |
populateConfig(ServiceLocator serviceLocator)
|
|
void |
populateServiceLocator(String name,
ServiceLocator serviceLocator)
Creates a ServiceLocator from all the modules in this registry |
|
void |
print(Logger logger)
Print a Registry dump to the logger |
|
|
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 |
remove(Module module)
Removes a module from the registry. |
|
void |
removeRepository(String name)
Remove a repository from the list of attached repositories to this instances. |
|
|
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 class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.sun.enterprise.module.ModulesRegistry |
---|
createChild, detachAll, find, getModulesClassLoader, getModulesClassLoader, getParentClassLoader, register, setParentClassLoader, shutdown, unregister |
Field Detail |
---|
protected final AbstractModulesRegistryImpl parent
ModulesRegistry
can form a tree structure by using this pointer.
It works in a way similar to the classloader tree. Modules defined in the parent
are visible to children.
protected final ConcurrentMap<ModuleId,Module> modules
protected final Map<Integer,Repository> repositories
protected final Map<String,Module> providers
This is used for the classloader punch-in hack — to work nicely with classic service loader implementation, we need to be able to allow any modules to see these classes.
Constructor Detail |
---|
protected AbstractModulesRegistryImpl(AbstractModulesRegistryImpl parent)
Method Detail |
---|
public ServiceLocator newServiceLocator() throws ComponentException
Habitat
newServiceLocator
in interface ModulesRegistry
ComponentException
public ServiceLocator newServiceLocator(ServiceLocator parent, String name) throws ComponentException
ComponentException
protected void initializeServiceLocator(ServiceLocator serviceLocator) throws ComponentException
ComponentException
public void populateServiceLocator(String name, ServiceLocator serviceLocator) throws ComponentException
ServiceLocator
from all the modules in this registry
populateServiceLocator
in interface ModulesRegistry
name
- Determines which descriptors are loaded.serviceLocator
- Habitat to initialize, null if it should be created
ComponentException
protected void populateConfig(ServiceLocator serviceLocator) throws BootException
BootException
public ServiceLocator createServiceLocator(String name) throws ComponentException
ModulesRegistry
ServiceLocator
from all the modules in this registry
Cal;ling this method has the same effect of calling ModulesRegistry.newServiceLocator()
followed by
ModulesRegistry.populateServiceLocator(String, ServiceLocator)
.
createServiceLocator
in interface ModulesRegistry
name
- Determines which inhabitants descriptors are loaded.
(so that different parallel habitats can be
created over the same modules registry.)
ComponentException
protected abstract void parseInhabitants(Module module, String name, ServiceLocator serviceLocator) throws IOException, BootException
IOException
BootException
public void addRepository(Repository repository, int weight)
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).
addRepository
in interface ModulesRegistry
repository
- new repository to attach to this registryweight
- int value from 1 to 100 to specify the search orderpublic void addRepository(Repository repository)
Repository
to this registry. From now on
the repository will be used to procure requested nodule not
registered in this instance.
addRepository
in interface ModulesRegistry
repository
- new repository to attach to this registrypublic void removeRepository(String name)
Repository
name will not be used to procure missing modules any
longer
removeRepository
in interface ModulesRegistry
name
- name of the repository to removepublic Repository getRepository(String name)
getRepository
in interface ModulesRegistry
name
- name of the repository to return
public Module makeModuleFor(String name, String version) throws ResolveError
Module
instance giving a name and version
constraints.
makeModuleFor
in interface ModulesRegistry
name
- the module nameversion
- the module version.
ResolveError
- if the module dependencies cannot be resolvedpublic Module makeModuleFor(String name, String version, boolean resolve) throws ResolveError
ModulesRegistry
Module
instance giving a name and version
constraints.
makeModuleFor
in interface ModulesRegistry
name
- the module nameversion
- the module version. Caller should specify a correct version.resolve
- should the module be resolved or not
ResolveError
- if the module dependencies cannot be resolvedpublic Module makeModuleFor(String packageName) throws ResolveError
makeModuleFor
in interface ModulesRegistry
packageName
- the requested implementation package name.
Module
instance implementing the package
name or null if not found.
ResolveError
- if the module dependencies cannot be resolvedprotected Module loadFromRepository(String name, String version)
protected abstract Module newModule(ModuleDefinition moduleDef)
moduleDef
- module definition of the new module to be created
protected void add(Module newModule)
newModule
- the new modulepublic InhabitantsParser createInhabitantsParser(ServiceLocator h)
createInhabitantsParser
in interface InhabitantsParserFactory
public void remove(Module module)
public Collection<Module> getModules()
The returned list will not include the modules defined in the ancestor
AbstractModulesRegistryImpl
s.
getModules
in interface ModulesRegistry
public Collection<Module> getModules(String moduleName)
ModulesRegistry
The returned list will not include the modules defined in the ancestor
ModulesRegistry
s.
getModules
in interface ModulesRegistry
public void changed(Module service)
changed
in interface ModuleChangeListener
public Module add(ModuleDefinition info) throws ResolveError
Module
instances.
add
in interface ModulesRegistry
ResolveError
public Module add(ModuleDefinition info, boolean resolve) throws ResolveError
ModulesRegistry
Module
instances.
add
in interface ModulesRegistry
info
- ModuleDefinition representing the new module contentresolve
- should the new module be resolved or not
ResolveError
public void print(Logger logger)
print
in interface ModulesRegistry
logger
- the logger to dump onpublic <T> Iterable<Class<? extends T>> getProvidersClass(Class<T> serviceClass)
getProvidersClass
in interface ModulesRegistry
public Iterable<Module> getModulesProvider(Class serviceClass)
getModulesProvider
in interface ModulesRegistry
serviceClass
- the service interface class
public <T> void registerRunningService(Class<T> serviceClass, T provider)
registerRunningService
in interface ModulesRegistry
serviceClass
- the service interfaceprovider
- the provider of that service.public <T> boolean unregisterRunningService(Class<T> serviceClass, T provider)
unregisterRunningService
in interface ModulesRegistry
public <T> List<T> getRunningServices(Class<T> serviceClass)
getRunningServices
in interface ModulesRegistry
serviceClass
- the service interface
public Module getProvidingModule(String providerClassName)
ModulesRegistry
Module
that provides the provider of the given name.
getProvidingModule
in interface ModulesRegistry
public void dumpState(PrintStream writer)
dumpState
in interface ModulesRegistry
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |