public class DefaultPlexusContainer extends AbstractLogEnabled implements MutablePlexusContainer
Modifier and Type | Field and Description |
---|---|
protected org.codehaus.plexus.classworlds.ClassWorld |
classWorld |
protected ComponentDiscovererManager |
componentDiscovererManager
Simple index (registry) of ComponentDiscovers and ComponentDiscoveryListener.
|
protected ComponentFactoryManager |
componentFactoryManager
Trivial class to look-up ComponentFactory instances in this container.
|
protected PlexusConfiguration |
configuration |
protected Reader |
configurationReader |
protected ConfigurationSource |
configurationSource
Converts a ComponentDescriptor into PlexusConfiguration.
|
protected Context |
containerContext
Arbitrary data associated with the container.
|
protected org.codehaus.plexus.classworlds.realm.ClassRealm |
containerRealm |
protected static String |
DEFAULT_CONTAINER_NAME |
protected static String |
DEFAULT_REALM_NAME |
protected LoggerManager |
loggerManager
Generic logger interface.
|
ROLE
Constructor and Description |
---|
DefaultPlexusContainer() |
DefaultPlexusContainer(ContainerConfiguration c) |
Modifier and Type | Method and Description |
---|---|
void |
addComponent(Object component,
String role) |
void |
addComponent(Object component,
String role,
String roleHint) |
<T> void |
addComponent(T component,
Class<?> role,
String roleHint)
Adds live component instance to this container.
|
void |
addComponentDescriptor(ComponentDescriptor<?> componentDescriptor)
Adds a component descriptor to this container.
|
void |
addContextValue(Object key,
Object value)
Add a key/value pair to this container's Context.
|
org.codehaus.plexus.classworlds.realm.ClassRealm |
createChildRealm(String id) |
List<ComponentDescriptor<?>> |
discoverComponents(org.codehaus.plexus.classworlds.realm.ClassRealm realm)
Discovers components in the given realm.
|
List<ComponentDescriptor<?>> |
discoverComponents(org.codehaus.plexus.classworlds.realm.ClassRealm realm,
Object data)
Discovers components in the given realm.
|
void |
dispose()
Disposes of this container, which in turn disposes all of it's components.
|
org.codehaus.plexus.classworlds.ClassWorld |
getClassWorld() |
<T> ComponentDescriptor<T> |
getComponentDescriptor(Class<T> type,
String role,
String roleHint)
Returns the ComponentDescriptor with the given component role and hint.
|
ComponentDescriptor<?> |
getComponentDescriptor(String role)
Returns the ComponentDescriptor with the given component role and the default role hint.
|
ComponentDescriptor<?> |
getComponentDescriptor(String role,
String roleHint)
Returns the ComponentDescriptor with the given component role and hint.
|
<T> List<ComponentDescriptor<T>> |
getComponentDescriptorList(Class<T> type,
String role)
Returns a List of ComponentDescriptors with the given role.
|
List<ComponentDescriptor<?>> |
getComponentDescriptorList(String role)
Returns a List of ComponentDescriptors with the given role.
|
<T> Map<String,ComponentDescriptor<T>> |
getComponentDescriptorMap(Class<T> type,
String role)
Returns a Map of ComponentDescriptors with the given role, keyed by role-hint.
|
Map<String,ComponentDescriptor<?>> |
getComponentDescriptorMap(String role)
Returns a Map of ComponentDescriptors with the given role, keyed by role-hint.
|
ComponentDiscovererManager |
getComponentDiscovererManager() |
ComponentFactoryManager |
getComponentFactoryManager() |
org.codehaus.plexus.classworlds.realm.ClassRealm |
getComponentRealm(String realmId) |
ComponentRegistry |
getComponentRegistry() |
PlexusConfiguration |
getConfiguration() |
ConfigurationSource |
getConfigurationSource() |
org.codehaus.plexus.classworlds.realm.ClassRealm |
getContainerRealm()
Returns the Classworld's ClassRealm of this Container, which acts as the default parent for all contained
components.
|
Context |
getContext()
Returns this container's context.
|
protected Reader |
getInterpolationConfigurationReader(Reader reader) |
Logger |
getLogger() |
LoggerManager |
getLoggerManager() |
org.codehaus.plexus.classworlds.realm.ClassRealm |
getLookupRealm()
Returns the lookup realm for this container, which is either
the container realm or the realm set by
PlexusContainer.setLookupRealm(ClassRealm) . |
org.codehaus.plexus.classworlds.realm.ClassRealm |
getLookupRealm(Object component)
Utility method to get a default lookup realm for a component.
|
boolean |
hasComponent(Class<?> type)
Returns true if this container has a component with the given role/role-hint.
|
boolean |
hasComponent(Class<?> type,
String roleHint)
Returns true if this container has a component with the given role/role-hint.
|
boolean |
hasComponent(Class<?> type,
String role,
String roleHint)
Returns true if this container has a component with the given role/role-hint.
|
boolean |
hasComponent(String role)
Returns true if this container has the keyed component.
|
boolean |
hasComponent(String role,
String roleHint)
Returns true if this container has a component with the given role/role-hint.
|
protected void |
initialize(ContainerConfiguration containerConfiguration) |
protected void |
initializeConfiguration(ContainerConfiguration c) |
protected void |
initializePhases(ContainerConfiguration containerConfiguration) |
<T> T |
lookup(Class<T> type)
Looks up and returns a component object with the given unique key or role.
|
<T> T |
lookup(Class<T> type,
String roleHint)
Looks up and returns a component object with the given unique role/role-hint combination.
|
<T> T |
lookup(Class<T> type,
String role,
String roleHint)
Looks up and returns a component object with the given unique role/role-hint combination.
|
<T> T |
lookup(ComponentDescriptor<T> componentDescriptor)
Looks up and returns a component object matching the given component descriptor.
|
Object |
lookup(String role)
Looks up and returns a component object with the given unique key or role.
|
Object |
lookup(String role,
String roleHint)
Looks up and returns a component object with the given unique role/role-hint combination.
|
<T> List<T> |
lookupList(Class<T> type)
Looks up and returns a List of component objects with the given role.
|
<T> List<T> |
lookupList(Class<T> type,
List<String> roleHints)
Looks up and returns a List of component objects with the given role.
|
List<Object> |
lookupList(String role)
Looks up and returns a List of component objects with the given role.
|
List<Object> |
lookupList(String role,
List<String> roleHints)
Looks up and returns a List of component objects with the given role.
|
<T> Map<String,T> |
lookupMap(Class<T> type)
Looks up and returns a Map of component objects with the given role, keyed by all available role-hints.
|
<T> Map<String,T> |
lookupMap(Class<T> type,
List<String> roleHints)
Looks up and returns a Map of component objects with the given role, keyed by all available role-hints.
|
Map<String,Object> |
lookupMap(String role)
Looks up and returns a Map of component objects with the given role, keyed by all available role-hints.
|
Map<String,Object> |
lookupMap(String role,
List<String> roleHints)
Looks up and returns a Map of component objects with the given role, keyed by all available role-hints.
|
void |
registerComponentDiscoveryListener(ComponentDiscoveryListener listener)
Adds the listener to this container.
|
void |
release(Object component)
Releases the component from the container.
|
void |
releaseAll(List<?> components)
Releases all Listed components from the container.
|
void |
releaseAll(Map<String,?> components)
Releases all Mapped component values from the container.
|
void |
removeComponentDiscoveryListener(ComponentDiscoveryListener listener)
Removes the listener from this container.
|
void |
removeComponentRealm(org.codehaus.plexus.classworlds.realm.ClassRealm realm)
Dissociate the realm with the specified id from the container.
|
void |
setClassWorld(org.codehaus.plexus.classworlds.ClassWorld classWorld) |
void |
setComponentDiscovererManager(ComponentDiscovererManager componentDiscovererManager) |
void |
setComponentFactoryManager(ComponentFactoryManager componentFactoryManager) |
void |
setComponentRegistry(ComponentRegistry componentRegistry) |
void |
setConfiguration(PlexusConfiguration configuration) |
void |
setConfigurationSource(ConfigurationSource configurationSource) |
void |
setContainerRealm(org.codehaus.plexus.classworlds.realm.ClassRealm containerRealm) |
void |
setLoggerManager(LoggerManager loggerManager) |
org.codehaus.plexus.classworlds.realm.ClassRealm |
setLookupRealm(org.codehaus.plexus.classworlds.realm.ClassRealm realm)
Sets the lookup realm to use for lookup calls that don't have a ClassRealm parameter.
|
protected void |
start() |
enableLogging, setupLogger, setupLogger, setupLogger
protected static final String DEFAULT_CONTAINER_NAME
protected static final String DEFAULT_REALM_NAME
protected Context containerContext
protected PlexusConfiguration configuration
protected Reader configurationReader
protected org.codehaus.plexus.classworlds.ClassWorld classWorld
protected org.codehaus.plexus.classworlds.realm.ClassRealm containerRealm
protected ComponentDiscovererManager componentDiscovererManager
protected ComponentFactoryManager componentFactoryManager
protected LoggerManager loggerManager
protected ConfigurationSource configurationSource
public DefaultPlexusContainer() throws PlexusContainerException
PlexusContainerException
public DefaultPlexusContainer(ContainerConfiguration c) throws PlexusContainerException
PlexusContainerException
public void addComponent(Object component, String role)
addComponent
in interface PlexusContainer
public <T> void addComponent(T component, Class<?> role, String roleHint)
PlexusContainer
addComponent
in interface PlexusContainer
T
- The type.component
- The component.role
- The role.roleHint
- The hint.public org.codehaus.plexus.classworlds.realm.ClassRealm setLookupRealm(org.codehaus.plexus.classworlds.realm.ClassRealm realm)
PlexusContainer
setLookupRealm
in interface PlexusContainer
realm
- the new realm to use.public org.codehaus.plexus.classworlds.realm.ClassRealm getLookupRealm()
PlexusContainer
PlexusContainer.setLookupRealm(ClassRealm)
.getLookupRealm
in interface PlexusContainer
ClassRealm
public org.codehaus.plexus.classworlds.realm.ClassRealm createChildRealm(String id)
createChildRealm
in interface PlexusContainer
public Object lookup(String role) throws ComponentLookupException
PlexusContainer
lookup
in interface PlexusContainer
role
- a unique key for the desired componentComponentLookupException
- in case of lookup error.public Object lookup(String role, String roleHint) throws ComponentLookupException
PlexusContainer
lookup
in interface PlexusContainer
role
- a non-unique key for the desired componentroleHint
- a hint for the desired component implementationComponentLookupException
- in case of lookup error.public <T> T lookup(Class<T> type) throws ComponentLookupException
PlexusContainer
lookup
in interface PlexusContainer
T
- The type.type
- the unique type of the component within the containerComponentLookupException
- in case of lookup error.public <T> T lookup(Class<T> type, String roleHint) throws ComponentLookupException
PlexusContainer
lookup
in interface PlexusContainer
T
- The type.type
- the non-unique type of the componentroleHint
- a hint for the desired component implementationComponentLookupException
- in case of lookup error.public <T> T lookup(Class<T> type, String role, String roleHint) throws ComponentLookupException
PlexusContainer
lookup
in interface PlexusContainer
T
- The type.type
- the non-unique type of the componentrole
- a non-unique key for the desired componentroleHint
- a hint for the desired component implementationComponentLookupException
- in case of lookup error.public <T> T lookup(ComponentDescriptor<T> componentDescriptor) throws ComponentLookupException
PlexusContainer
lookup
in interface PlexusContainer
T
- The type.componentDescriptor
- the descriptor of the componentComponentLookupException
- in case of lookup error.public List<Object> lookupList(String role) throws ComponentLookupException
PlexusContainer
lookupList
in interface PlexusContainer
role
- a non-unique key for the desired componentsComponentLookupException
- in case of lookup error.public List<Object> lookupList(String role, List<String> roleHints) throws ComponentLookupException
PlexusContainer
lookupList
in interface PlexusContainer
role
- a non-unique key for the desired componentsroleHints
- the list of hints.ComponentLookupException
- in case of lookup error.public <T> List<T> lookupList(Class<T> type) throws ComponentLookupException
PlexusContainer
lookupList
in interface PlexusContainer
T
- The type.type
- the non-unique type of the componentsComponentLookupException
- in case of lookup error.public <T> List<T> lookupList(Class<T> type, List<String> roleHints) throws ComponentLookupException
PlexusContainer
lookupList
in interface PlexusContainer
T
- The type.type
- the non-unique type of the componentsroleHints
- the list of hints.ComponentLookupException
- in case of lookup error.public Map<String,Object> lookupMap(String role) throws ComponentLookupException
PlexusContainer
lookupMap
in interface PlexusContainer
role
- a non-unique key for the desired componentsComponentLookupException
- in case of lookup error.public Map<String,Object> lookupMap(String role, List<String> roleHints) throws ComponentLookupException
PlexusContainer
lookupMap
in interface PlexusContainer
role
- a non-unique key for the desired componentsroleHints
- the list of hints.ComponentLookupException
- in case of lookup error.public <T> Map<String,T> lookupMap(Class<T> type) throws ComponentLookupException
PlexusContainer
lookupMap
in interface PlexusContainer
T
- The type.type
- the non-unique type of the componentsComponentLookupException
- in case of lookup error.public <T> Map<String,T> lookupMap(Class<T> type, List<String> roleHints) throws ComponentLookupException
PlexusContainer
lookupMap
in interface PlexusContainer
T
- The type.type
- the non-unique type of the componentsroleHints
- the list of hints.ComponentLookupException
- in case of lookup error.public boolean hasComponent(String role)
PlexusContainer
hasComponent
in interface PlexusContainer
role
- a non-unique key for the desired componentpublic boolean hasComponent(String role, String roleHint)
PlexusContainer
hasComponent
in interface PlexusContainer
role
- a non-unique key for the desired componentroleHint
- a hint for the desired component implementationpublic boolean hasComponent(Class<?> type)
PlexusContainer
hasComponent
in interface PlexusContainer
type
- the non-unique type of the componentpublic boolean hasComponent(Class<?> type, String roleHint)
PlexusContainer
hasComponent
in interface PlexusContainer
type
- the non-unique type of the componentroleHint
- a hint for the desired component implementationpublic boolean hasComponent(Class<?> type, String role, String roleHint)
PlexusContainer
hasComponent
in interface PlexusContainer
type
- the non-unique type of the componentrole
- a non-unique key for the desired componentroleHint
- a hint for the desired component implementationpublic ComponentDescriptor<?> getComponentDescriptor(String role)
PlexusContainer
getComponentDescriptor
in interface PlexusContainer
role
- a unique role for the desired component's descriptorpublic ComponentDescriptor<?> getComponentDescriptor(String role, String roleHint)
PlexusContainer
getComponentDescriptor
in interface PlexusContainer
role
- a unique role for the desired component's descriptorroleHint
- a hint showing which implementation should be usedpublic <T> ComponentDescriptor<T> getComponentDescriptor(Class<T> type, String role, String roleHint)
PlexusContainer
getComponentDescriptor
in interface PlexusContainer
T
- The type.type
- the Java type of the desired componentrole
- a unique role for the desired component's descriptorroleHint
- a hint showing which implementation should be usedpublic Map<String,ComponentDescriptor<?>> getComponentDescriptorMap(String role)
PlexusContainer
getComponentDescriptorMap
in interface PlexusContainer
role
- a non-unique key for the desired componentspublic <T> Map<String,ComponentDescriptor<T>> getComponentDescriptorMap(Class<T> type, String role)
PlexusContainer
getComponentDescriptorMap
in interface PlexusContainer
T
- The type.type
- the Java type of the desired componentsrole
- a non-unique key for the desired componentspublic List<ComponentDescriptor<?>> getComponentDescriptorList(String role)
PlexusContainer
getComponentDescriptorList
in interface PlexusContainer
role
- a non-unique key for the desired componentspublic <T> List<ComponentDescriptor<T>> getComponentDescriptorList(Class<T> type, String role)
PlexusContainer
getComponentDescriptorList
in interface PlexusContainer
T
- The type.type
- the Java type of the desired componentsrole
- a non-unique key for the desired componentspublic void addComponentDescriptor(ComponentDescriptor<?> componentDescriptor) throws CycleDetectedInComponentGraphException
PlexusContainer
addComponentDescriptor
in interface PlexusContainer
componentDescriptor
- ComponentDescriptor
CycleDetectedInComponentGraphException
- In case of an error.public void release(Object component) throws ComponentLifecycleException
PlexusContainer
release
in interface PlexusContainer
component
- the plexus component object to releaseComponentLifecycleException
- in case of an error.public void releaseAll(Map<String,?> components) throws ComponentLifecycleException
PlexusContainer
releaseAll
in interface PlexusContainer
components
- Map of plexus component objects to releaseComponentLifecycleException
- in case of an error.PlexusContainer.release( Object component )
public void releaseAll(List<?> components) throws ComponentLifecycleException
PlexusContainer
releaseAll
in interface PlexusContainer
components
- List of plexus component objects to releaseComponentLifecycleException
- in case of an error.PlexusContainer.release( Object component )
protected void initialize(ContainerConfiguration containerConfiguration) throws PlexusContainerException
PlexusContainerException
protected void initializePhases(ContainerConfiguration containerConfiguration) throws PlexusContainerException
PlexusContainerException
protected void start() throws PlexusContainerException
PlexusContainerException
public void dispose()
PlexusContainer
dispose
in interface PlexusContainer
public void addContextValue(Object key, Object value)
PlexusContainer
addContextValue
in interface PlexusContainer
key
- any unique object valid to the Context's implementationvalue
- any object valid to the Context's implementationpublic org.codehaus.plexus.classworlds.ClassWorld getClassWorld()
getClassWorld
in interface MutablePlexusContainer
public void setClassWorld(org.codehaus.plexus.classworlds.ClassWorld classWorld)
public org.codehaus.plexus.classworlds.realm.ClassRealm getContainerRealm()
PlexusContainer
getContainerRealm
in interface PlexusContainer
public void setContainerRealm(org.codehaus.plexus.classworlds.realm.ClassRealm containerRealm)
public Context getContext()
PlexusContainer
getContext
in interface PlexusContainer
protected void initializeConfiguration(ContainerConfiguration c) throws PlexusConfigurationException, ContextException, IOException
protected Reader getInterpolationConfigurationReader(Reader reader)
public Logger getLogger()
getLogger
in interface MutablePlexusContainer
getLogger
in class AbstractLogEnabled
public void registerComponentDiscoveryListener(ComponentDiscoveryListener listener)
PlexusContainer
registerComponentDiscoveryListener
in interface PlexusContainer
listener
- A listener which responds to different ComponentDiscoveryEventspublic void removeComponentDiscoveryListener(ComponentDiscoveryListener listener)
PlexusContainer
removeComponentDiscoveryListener
in interface PlexusContainer
listener
- A listener to removepublic ComponentRegistry getComponentRegistry()
getComponentRegistry
in interface MutablePlexusContainer
public void setComponentRegistry(ComponentRegistry componentRegistry)
setComponentRegistry
in interface MutablePlexusContainer
public ComponentDiscovererManager getComponentDiscovererManager()
getComponentDiscovererManager
in interface MutablePlexusContainer
public void setComponentDiscovererManager(ComponentDiscovererManager componentDiscovererManager)
setComponentDiscovererManager
in interface MutablePlexusContainer
public ComponentFactoryManager getComponentFactoryManager()
getComponentFactoryManager
in interface MutablePlexusContainer
public void setComponentFactoryManager(ComponentFactoryManager componentFactoryManager)
setComponentFactoryManager
in interface MutablePlexusContainer
public PlexusConfiguration getConfiguration()
getConfiguration
in interface MutablePlexusContainer
public void setConfiguration(PlexusConfiguration configuration)
setConfiguration
in interface MutablePlexusContainer
public org.codehaus.plexus.classworlds.realm.ClassRealm getComponentRealm(String realmId)
getComponentRealm
in interface MutablePlexusContainer
getComponentRealm
in interface PlexusContainer
public void removeComponentRealm(org.codehaus.plexus.classworlds.realm.ClassRealm realm) throws PlexusContainerException
PlexusContainer
removeComponentRealm
in interface PlexusContainer
realm
- Realm to remove from the container.PlexusContainerException
- PlexusContainerException
.public org.codehaus.plexus.classworlds.realm.ClassRealm getLookupRealm(Object component)
getLookupRealm
in interface PlexusContainer
component
- The component.ClassRealm
public void setConfigurationSource(ConfigurationSource configurationSource)
setConfigurationSource
in interface MutablePlexusContainer
public ConfigurationSource getConfigurationSource()
getConfigurationSource
in interface MutablePlexusContainer
public LoggerManager getLoggerManager()
getLoggerManager
in interface MutablePlexusContainer
public void setLoggerManager(LoggerManager loggerManager)
setLoggerManager
in interface MutablePlexusContainer
public List<ComponentDescriptor<?>> discoverComponents(org.codehaus.plexus.classworlds.realm.ClassRealm realm) throws PlexusConfigurationException, CycleDetectedInComponentGraphException
PlexusContainer
discoverComponents
in interface PlexusContainer
realm
- ClassRealm
ComponentDescriptor
PlexusConfigurationException
- in case of an error.CycleDetectedInComponentGraphException
- in case of an error.public List<ComponentDescriptor<?>> discoverComponents(org.codehaus.plexus.classworlds.realm.ClassRealm realm, Object data) throws PlexusConfigurationException, CycleDetectedInComponentGraphException
PlexusContainer
discoverComponents
in interface PlexusContainer
realm
- the ClassRealm
.data
- The data.ComponentDescriptor
PlexusConfigurationException
- in case of an error.CycleDetectedInComponentGraphException
- in case of an error.Copyright © 2001–2019 Codehaus Plexus. All rights reserved.