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, setupLoggerprotected 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
PlexusContainerExceptionpublic DefaultPlexusContainer(ContainerConfiguration c) throws PlexusContainerException
PlexusContainerExceptionpublic void addComponent(Object component, String role)
addComponent in interface PlexusContainerpublic <T> void addComponent(T component,
Class<?> role,
String roleHint)
PlexusContaineraddComponent in interface PlexusContainerT - 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)
PlexusContainersetLookupRealm in interface PlexusContainerrealm - the new realm to use.public org.codehaus.plexus.classworlds.realm.ClassRealm getLookupRealm()
PlexusContainerPlexusContainer.setLookupRealm(ClassRealm).getLookupRealm in interface PlexusContainerClassRealmpublic org.codehaus.plexus.classworlds.realm.ClassRealm createChildRealm(String id)
createChildRealm in interface PlexusContainerpublic Object lookup(String role) throws ComponentLookupException
PlexusContainerlookup in interface PlexusContainerrole - a unique key for the desired componentComponentLookupException - in case of lookup error.public Object lookup(String role, String roleHint) throws ComponentLookupException
PlexusContainerlookup in interface PlexusContainerrole - 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
PlexusContainerlookup in interface PlexusContainerT - 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
PlexusContainerlookup in interface PlexusContainerT - 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
PlexusContainerlookup in interface PlexusContainerT - 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
PlexusContainerlookup in interface PlexusContainerT - The type.componentDescriptor - the descriptor of the componentComponentLookupException - in case of lookup error.public List<Object> lookupList(String role) throws ComponentLookupException
PlexusContainerlookupList in interface PlexusContainerrole - a non-unique key for the desired componentsComponentLookupException - in case of lookup error.public List<Object> lookupList(String role, List<String> roleHints) throws ComponentLookupException
PlexusContainerlookupList in interface PlexusContainerrole - 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
PlexusContainerlookupList in interface PlexusContainerT - 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
PlexusContainerlookupList in interface PlexusContainerT - 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
PlexusContainerlookupMap in interface PlexusContainerrole - 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
PlexusContainerlookupMap in interface PlexusContainerrole - 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
PlexusContainerlookupMap in interface PlexusContainerT - 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
PlexusContainerlookupMap in interface PlexusContainerT - 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)
PlexusContainerhasComponent in interface PlexusContainerrole - a non-unique key for the desired componentpublic boolean hasComponent(String role, String roleHint)
PlexusContainerhasComponent in interface PlexusContainerrole - a non-unique key for the desired componentroleHint - a hint for the desired component implementationpublic boolean hasComponent(Class<?> type)
PlexusContainerhasComponent in interface PlexusContainertype - the non-unique type of the componentpublic boolean hasComponent(Class<?> type, String roleHint)
PlexusContainerhasComponent in interface PlexusContainertype - the non-unique type of the componentroleHint - a hint for the desired component implementationpublic boolean hasComponent(Class<?> type, String role, String roleHint)
PlexusContainerhasComponent in interface PlexusContainertype - 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)
PlexusContainergetComponentDescriptor in interface PlexusContainerrole - a unique role for the desired component's descriptorpublic ComponentDescriptor<?> getComponentDescriptor(String role, String roleHint)
PlexusContainergetComponentDescriptor in interface PlexusContainerrole - 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)
PlexusContainergetComponentDescriptor in interface PlexusContainerT - 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)
PlexusContainergetComponentDescriptorMap in interface PlexusContainerrole - a non-unique key for the desired componentspublic <T> Map<String,ComponentDescriptor<T>> getComponentDescriptorMap(Class<T> type, String role)
PlexusContainergetComponentDescriptorMap in interface PlexusContainerT - The type.type - the Java type of the desired componentsrole - a non-unique key for the desired componentspublic List<ComponentDescriptor<?>> getComponentDescriptorList(String role)
PlexusContainergetComponentDescriptorList in interface PlexusContainerrole - a non-unique key for the desired componentspublic <T> List<ComponentDescriptor<T>> getComponentDescriptorList(Class<T> type, String role)
PlexusContainergetComponentDescriptorList in interface PlexusContainerT - The type.type - the Java type of the desired componentsrole - a non-unique key for the desired componentspublic void addComponentDescriptor(ComponentDescriptor<?> componentDescriptor) throws CycleDetectedInComponentGraphException
PlexusContaineraddComponentDescriptor in interface PlexusContainercomponentDescriptor - ComponentDescriptorCycleDetectedInComponentGraphException - In case of an error.public void release(Object component) throws ComponentLifecycleException
PlexusContainerrelease in interface PlexusContainercomponent - the plexus component object to releaseComponentLifecycleException - in case of an error.public void releaseAll(Map<String,?> components) throws ComponentLifecycleException
PlexusContainerreleaseAll in interface PlexusContainercomponents - Map of plexus component objects to releaseComponentLifecycleException - in case of an error.PlexusContainer.release( Object component )public void releaseAll(List<?> components) throws ComponentLifecycleException
PlexusContainerreleaseAll in interface PlexusContainercomponents - List of plexus component objects to releaseComponentLifecycleException - in case of an error.PlexusContainer.release( Object component )protected void initialize(ContainerConfiguration containerConfiguration) throws PlexusContainerException
PlexusContainerExceptionprotected void initializePhases(ContainerConfiguration containerConfiguration) throws PlexusContainerException
PlexusContainerExceptionprotected void start()
throws PlexusContainerException
PlexusContainerExceptionpublic void dispose()
PlexusContainerdispose in interface PlexusContainerpublic void addContextValue(Object key, Object value)
PlexusContaineraddContextValue in interface PlexusContainerkey - 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 MutablePlexusContainerpublic void setClassWorld(org.codehaus.plexus.classworlds.ClassWorld classWorld)
public org.codehaus.plexus.classworlds.realm.ClassRealm getContainerRealm()
PlexusContainergetContainerRealm in interface PlexusContainerpublic void setContainerRealm(org.codehaus.plexus.classworlds.realm.ClassRealm containerRealm)
public Context getContext()
PlexusContainergetContext in interface PlexusContainerprotected void initializeConfiguration(ContainerConfiguration c) throws PlexusConfigurationException, ContextException, IOException
protected Reader getInterpolationConfigurationReader(Reader reader)
public Logger getLogger()
getLogger in interface MutablePlexusContainergetLogger in class AbstractLogEnabledpublic void registerComponentDiscoveryListener(ComponentDiscoveryListener listener)
PlexusContainerregisterComponentDiscoveryListener in interface PlexusContainerlistener - A listener which responds to different ComponentDiscoveryEventspublic void removeComponentDiscoveryListener(ComponentDiscoveryListener listener)
PlexusContainerremoveComponentDiscoveryListener in interface PlexusContainerlistener - A listener to removepublic ComponentRegistry getComponentRegistry()
getComponentRegistry in interface MutablePlexusContainerpublic void setComponentRegistry(ComponentRegistry componentRegistry)
setComponentRegistry in interface MutablePlexusContainerpublic ComponentDiscovererManager getComponentDiscovererManager()
getComponentDiscovererManager in interface MutablePlexusContainerpublic void setComponentDiscovererManager(ComponentDiscovererManager componentDiscovererManager)
setComponentDiscovererManager in interface MutablePlexusContainerpublic ComponentFactoryManager getComponentFactoryManager()
getComponentFactoryManager in interface MutablePlexusContainerpublic void setComponentFactoryManager(ComponentFactoryManager componentFactoryManager)
setComponentFactoryManager in interface MutablePlexusContainerpublic PlexusConfiguration getConfiguration()
getConfiguration in interface MutablePlexusContainerpublic void setConfiguration(PlexusConfiguration configuration)
setConfiguration in interface MutablePlexusContainerpublic org.codehaus.plexus.classworlds.realm.ClassRealm getComponentRealm(String realmId)
getComponentRealm in interface MutablePlexusContainergetComponentRealm in interface PlexusContainerpublic void removeComponentRealm(org.codehaus.plexus.classworlds.realm.ClassRealm realm)
throws PlexusContainerException
PlexusContainerremoveComponentRealm in interface PlexusContainerrealm - Realm to remove from the container.PlexusContainerException - PlexusContainerException.public org.codehaus.plexus.classworlds.realm.ClassRealm getLookupRealm(Object component)
getLookupRealm in interface PlexusContainercomponent - The component.ClassRealmpublic void setConfigurationSource(ConfigurationSource configurationSource)
setConfigurationSource in interface MutablePlexusContainerpublic ConfigurationSource getConfigurationSource()
getConfigurationSource in interface MutablePlexusContainerpublic LoggerManager getLoggerManager()
getLoggerManager in interface MutablePlexusContainerpublic void setLoggerManager(LoggerManager loggerManager)
setLoggerManager in interface MutablePlexusContainerpublic List<ComponentDescriptor<?>> discoverComponents(org.codehaus.plexus.classworlds.realm.ClassRealm realm) throws PlexusConfigurationException, CycleDetectedInComponentGraphException
PlexusContainerdiscoverComponents in interface PlexusContainerrealm - ClassRealmComponentDescriptorPlexusConfigurationException - 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
PlexusContainerdiscoverComponents in interface PlexusContainerrealm - the ClassRealm.data - The data.ComponentDescriptorPlexusConfigurationException - in case of an error.CycleDetectedInComponentGraphException - in case of an error.Copyright © 2001–2019 Codehaus Plexus. All rights reserved.