|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.plexus.logging.AbstractLogEnabled
org.codehaus.plexus.DefaultPlexusContainer
public class DefaultPlexusContainer
Default implementation of PlexusContainer and MutablePlexusContainer.
Field Summary | |
---|---|
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 java.io.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 java.lang.String |
DEFAULT_CONTAINER_NAME
|
protected static java.lang.String |
DEFAULT_REALM_NAME
|
protected LoggerManager |
loggerManager
Generic logger interface. |
Fields inherited from interface org.codehaus.plexus.PlexusContainer |
---|
ROLE |
Constructor Summary | |
---|---|
DefaultPlexusContainer()
|
|
DefaultPlexusContainer(ContainerConfiguration c)
|
Method Summary | ||
---|---|---|
void |
addComponent(java.lang.Object component,
java.lang.String role)
|
|
void |
addComponent(java.lang.Object component,
java.lang.String role,
java.lang.String roleHint)
|
|
|
addComponent(T component,
java.lang.Class<?> role,
java.lang.String roleHint)
Adds live component instance to this container. |
|
void |
addComponentDescriptor(ComponentDescriptor<?> componentDescriptor)
Adds a component descriptor to this container. componentDescriptor should have realmId set. |
|
void |
addContextValue(java.lang.Object key,
java.lang.Object value)
Add a key/value pair to this container's Context. |
|
org.codehaus.plexus.classworlds.realm.ClassRealm |
createChildRealm(java.lang.String id)
|
|
java.util.List<ComponentDescriptor<?>> |
discoverComponents(org.codehaus.plexus.classworlds.realm.ClassRealm realm)
Discovers components in the given realm. |
|
java.util.List<ComponentDescriptor<?>> |
discoverComponents(org.codehaus.plexus.classworlds.realm.ClassRealm realm,
java.lang.Object data)
|
|
void |
dispose()
Disposes of this container, which in turn disposes all of it's components. |
|
org.codehaus.plexus.classworlds.ClassWorld |
getClassWorld()
|
|
|
getComponentDescriptor(java.lang.Class<T> type,
java.lang.String role,
java.lang.String roleHint)
Returns the ComponentDescriptor with the given component role and hint. |
|
ComponentDescriptor<?> |
getComponentDescriptor(java.lang.String role)
Returns the ComponentDescriptor with the given component role and the default role hint. |
|
ComponentDescriptor<?> |
getComponentDescriptor(java.lang.String role,
java.lang.String roleHint)
Returns the ComponentDescriptor with the given component role and hint. |
|
|
getComponentDescriptorList(java.lang.Class<T> type,
java.lang.String role)
Returns a List of ComponentDescriptors with the given role. |
|
java.util.List<ComponentDescriptor<?>> |
getComponentDescriptorList(java.lang.String role)
Returns a List of ComponentDescriptors with the given role. |
|
|
getComponentDescriptorMap(java.lang.Class<T> type,
java.lang.String role)
Returns a Map of ComponentDescriptors with the given role, keyed by role-hint. |
|
java.util.Map<java.lang.String,ComponentDescriptor<?>> |
getComponentDescriptorMap(java.lang.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(java.lang.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 java.io.Reader |
getInterpolationConfigurationReader(java.io.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(java.lang.Object component)
Utility method to get a default lookup realm for a component. |
|
boolean |
hasComponent(java.lang.Class<?> type)
Returns true if this container has a component with the given role/role-hint. |
|
boolean |
hasComponent(java.lang.Class<?> type,
java.lang.String roleHint)
Returns true if this container has a component with the given role/role-hint. |
|
boolean |
hasComponent(java.lang.Class<?> type,
java.lang.String role,
java.lang.String roleHint)
Returns true if this container has a component with the given role/role-hint. |
|
boolean |
hasComponent(java.lang.String role)
Returns true if this container has the keyed component. |
|
boolean |
hasComponent(java.lang.String role,
java.lang.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)
|
|
|
lookup(java.lang.Class<T> type)
Looks up and returns a component object with the given unique key or role. |
|
|
lookup(java.lang.Class<T> type,
java.lang.String roleHint)
Looks up and returns a component object with the given unique role/role-hint combination. |
|
|
lookup(java.lang.Class<T> type,
java.lang.String role,
java.lang.String roleHint)
Looks up and returns a component object with the given unique role/role-hint combination. |
|
|
lookup(ComponentDescriptor<T> componentDescriptor)
Looks up and returns a component object matching the given component descriptor. |
|
java.lang.Object |
lookup(java.lang.String role)
Looks up and returns a component object with the given unique key or role. |
|
java.lang.Object |
lookup(java.lang.String role,
java.lang.String roleHint)
Looks up and returns a component object with the given unique role/role-hint combination. |
|
|
lookupList(java.lang.Class<T> type)
Looks up and returns a List of component objects with the given role. |
|
|
lookupList(java.lang.Class<T> type,
java.util.List<java.lang.String> roleHints)
Looks up and returns a List of component objects with the given role. |
|
java.util.List<java.lang.Object> |
lookupList(java.lang.String role)
Looks up and returns a List of component objects with the given role. |
|
java.util.List<java.lang.Object> |
lookupList(java.lang.String role,
java.util.List<java.lang.String> roleHints)
Looks up and returns a List of component objects with the given role. |
|
|
lookupMap(java.lang.Class<T> type)
Looks up and returns a Map of component objects with the given role, keyed by all available role-hints. |
|
|
lookupMap(java.lang.Class<T> type,
java.util.List<java.lang.String> roleHints)
Looks up and returns a Map of component objects with the given role, keyed by all available role-hints. |
|
java.util.Map<java.lang.String,java.lang.Object> |
lookupMap(java.lang.String role)
Looks up and returns a Map of component objects with the given role, keyed by all available role-hints. |
|
java.util.Map<java.lang.String,java.lang.Object> |
lookupMap(java.lang.String role,
java.util.List<java.lang.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(java.lang.Object component)
Releases the component from the container. |
|
void |
releaseAll(java.util.List<?> components)
Releases all Listed components from the container. |
|
void |
releaseAll(java.util.Map<java.lang.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()
|
Methods inherited from class org.codehaus.plexus.logging.AbstractLogEnabled |
---|
enableLogging, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String DEFAULT_CONTAINER_NAME
protected static final java.lang.String DEFAULT_REALM_NAME
protected Context containerContext
protected PlexusConfiguration configuration
protected java.io.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
Constructor Detail |
---|
public DefaultPlexusContainer() throws PlexusContainerException
PlexusContainerException
public DefaultPlexusContainer(ContainerConfiguration c) throws PlexusContainerException
PlexusContainerException
Method Detail |
---|
public void addComponent(java.lang.Object component, java.lang.String role)
addComponent
in interface PlexusContainer
public <T> void addComponent(T component, java.lang.Class<?> role, java.lang.String roleHint)
PlexusContainer
addComponent
in interface PlexusContainer
public void addComponent(java.lang.Object component, java.lang.String role, java.lang.String roleHint)
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
public org.codehaus.plexus.classworlds.realm.ClassRealm createChildRealm(java.lang.String id)
createChildRealm
in interface PlexusContainer
public java.lang.Object lookup(java.lang.String role) throws ComponentLookupException
PlexusContainer
lookup
in interface PlexusContainer
role
- a unique key for the desired component
ComponentLookupException
public java.lang.Object lookup(java.lang.String role, java.lang.String roleHint) throws ComponentLookupException
PlexusContainer
lookup
in interface PlexusContainer
role
- a non-unique key for the desired componentroleHint
- a hint for the desired component implementation
ComponentLookupException
public <T> T lookup(java.lang.Class<T> type) throws ComponentLookupException
PlexusContainer
lookup
in interface PlexusContainer
type
- the unique type of the component within the container
ComponentLookupException
public <T> T lookup(java.lang.Class<T> type, java.lang.String roleHint) throws ComponentLookupException
PlexusContainer
lookup
in interface PlexusContainer
type
- the non-unique type of the componentroleHint
- a hint for the desired component implementation
ComponentLookupException
public <T> T lookup(java.lang.Class<T> type, java.lang.String role, java.lang.String roleHint) throws ComponentLookupException
PlexusContainer
lookup
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 implementation
ComponentLookupException
public <T> T lookup(ComponentDescriptor<T> componentDescriptor) throws ComponentLookupException
PlexusContainer
lookup
in interface PlexusContainer
componentDescriptor
- the descriptor of the component
ComponentLookupException
public java.util.List<java.lang.Object> lookupList(java.lang.String role) throws ComponentLookupException
PlexusContainer
lookupList
in interface PlexusContainer
role
- a non-unique key for the desired components
ComponentLookupException
public java.util.List<java.lang.Object> lookupList(java.lang.String role, java.util.List<java.lang.String> roleHints) throws ComponentLookupException
PlexusContainer
lookupList
in interface PlexusContainer
role
- a non-unique key for the desired components
ComponentLookupException
public <T> java.util.List<T> lookupList(java.lang.Class<T> type) throws ComponentLookupException
PlexusContainer
lookupList
in interface PlexusContainer
type
- the non-unique type of the components
ComponentLookupException
public <T> java.util.List<T> lookupList(java.lang.Class<T> type, java.util.List<java.lang.String> roleHints) throws ComponentLookupException
PlexusContainer
lookupList
in interface PlexusContainer
type
- the non-unique type of the components
ComponentLookupException
public java.util.Map<java.lang.String,java.lang.Object> lookupMap(java.lang.String role) throws ComponentLookupException
PlexusContainer
lookupMap
in interface PlexusContainer
role
- a non-unique key for the desired components
ComponentLookupException
public java.util.Map<java.lang.String,java.lang.Object> lookupMap(java.lang.String role, java.util.List<java.lang.String> roleHints) throws ComponentLookupException
PlexusContainer
lookupMap
in interface PlexusContainer
role
- a non-unique key for the desired components
ComponentLookupException
public <T> java.util.Map<java.lang.String,T> lookupMap(java.lang.Class<T> type) throws ComponentLookupException
PlexusContainer
lookupMap
in interface PlexusContainer
type
- the non-unique type of the components
ComponentLookupException
public <T> java.util.Map<java.lang.String,T> lookupMap(java.lang.Class<T> type, java.util.List<java.lang.String> roleHints) throws ComponentLookupException
PlexusContainer
lookupMap
in interface PlexusContainer
type
- the non-unique type of the components
ComponentLookupException
public boolean hasComponent(java.lang.String role)
PlexusContainer
hasComponent
in interface PlexusContainer
role
- a non-unique key for the desired component
public boolean hasComponent(java.lang.String role, java.lang.String roleHint)
PlexusContainer
hasComponent
in interface PlexusContainer
role
- a non-unique key for the desired componentroleHint
- a hint for the desired component implementation
public boolean hasComponent(java.lang.Class<?> type)
PlexusContainer
hasComponent
in interface PlexusContainer
type
- the non-unique type of the component
public boolean hasComponent(java.lang.Class<?> type, java.lang.String roleHint)
PlexusContainer
hasComponent
in interface PlexusContainer
type
- the non-unique type of the componentroleHint
- a hint for the desired component implementation
public boolean hasComponent(java.lang.Class<?> type, java.lang.String role, java.lang.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 implementation
public ComponentDescriptor<?> getComponentDescriptor(java.lang.String role)
PlexusContainer
getComponentDescriptor
in interface PlexusContainer
role
- a unique role for the desired component's descriptor
public ComponentDescriptor<?> getComponentDescriptor(java.lang.String role, java.lang.String roleHint)
PlexusContainer
getComponentDescriptor
in interface PlexusContainer
role
- a unique role for the desired component's descriptorroleHint
- a hint showing which implementation should be used
public <T> ComponentDescriptor<T> getComponentDescriptor(java.lang.Class<T> type, java.lang.String role, java.lang.String roleHint)
PlexusContainer
getComponentDescriptor
in interface PlexusContainer
type
- the Java type of the desired componentrole
- a unique role for the desired component's descriptorroleHint
- a hint showing which implementation should be used
public java.util.Map<java.lang.String,ComponentDescriptor<?>> getComponentDescriptorMap(java.lang.String role)
PlexusContainer
getComponentDescriptorMap
in interface PlexusContainer
role
- a non-unique key for the desired components
public <T> java.util.Map<java.lang.String,ComponentDescriptor<T>> getComponentDescriptorMap(java.lang.Class<T> type, java.lang.String role)
PlexusContainer
getComponentDescriptorMap
in interface PlexusContainer
type
- the Java type of the desired componentsrole
- a non-unique key for the desired components
public java.util.List<ComponentDescriptor<?>> getComponentDescriptorList(java.lang.String role)
PlexusContainer
getComponentDescriptorList
in interface PlexusContainer
role
- a non-unique key for the desired components
public <T> java.util.List<ComponentDescriptor<T>> getComponentDescriptorList(java.lang.Class<T> type, java.lang.String role)
PlexusContainer
getComponentDescriptorList
in interface PlexusContainer
type
- the Java type of the desired componentsrole
- a non-unique key for the desired components
public void addComponentDescriptor(ComponentDescriptor<?> componentDescriptor) throws CycleDetectedInComponentGraphException
PlexusContainer
addComponentDescriptor
in interface PlexusContainer
CycleDetectedInComponentGraphException
public void release(java.lang.Object component) throws ComponentLifecycleException
PlexusContainer
release
in interface PlexusContainer
component
- the plexus component object to release
ComponentLifecycleException
public void releaseAll(java.util.Map<java.lang.String,?> components) throws ComponentLifecycleException
PlexusContainer
releaseAll
in interface PlexusContainer
components
- Map of plexus component objects to release
ComponentLifecycleException
PlexusContainer.release( Object component )
public void releaseAll(java.util.List<?> components) throws ComponentLifecycleException
PlexusContainer
releaseAll
in interface PlexusContainer
components
- List of plexus component objects to release
ComponentLifecycleException
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(java.lang.Object key, java.lang.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, java.io.IOException
PlexusConfigurationException
ContextException
java.io.IOException
protected java.io.Reader getInterpolationConfigurationReader(java.io.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(java.lang.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
public org.codehaus.plexus.classworlds.realm.ClassRealm getLookupRealm(java.lang.Object component)
getLookupRealm
in interface PlexusContainer
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 java.util.List<ComponentDescriptor<?>> discoverComponents(org.codehaus.plexus.classworlds.realm.ClassRealm realm) throws PlexusConfigurationException, CycleDetectedInComponentGraphException
PlexusContainer
discoverComponents
in interface PlexusContainer
PlexusConfigurationException
CycleDetectedInComponentGraphException
public java.util.List<ComponentDescriptor<?>> discoverComponents(org.codehaus.plexus.classworlds.realm.ClassRealm realm, java.lang.Object data) throws PlexusConfigurationException, CycleDetectedInComponentGraphException
discoverComponents
in interface PlexusContainer
PlexusConfigurationException
CycleDetectedInComponentGraphException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |