org.codehaus.plexus
Class DefaultPlexusContainer

java.lang.Object
  extended by org.codehaus.plexus.logging.AbstractLogEnabled
      extended by org.codehaus.plexus.DefaultPlexusContainer
All Implemented Interfaces:
LogEnabled, MutablePlexusContainer, PlexusContainer

public class DefaultPlexusContainer
extends AbstractLogEnabled
implements MutablePlexusContainer

//todo move lookup code to a separate component //todo register live components so they can be wired //keep track of the interfaces for components //todo allow setting of a live configuraton so applications that embed plexus can use whatever configuration mechanism they like. They just have to adapt it into something plexus can understand. //todo make a typesafe configuration model for the container //todo pico like registration //todo need loggers per execution like in the maven embedder //todo a simple front-end to make containers of different flavours, a flavour encapsulating // a set of behaviours //todo the core components should probably have a small lifecycle to pass through

Author:
Jason van Zyl

Field Summary
protected  java.util.Map childContainers
           
protected  org.codehaus.classworlds.ClassWorld classWorld
           
protected  ComponentComposerManager componentComposerManager
           
protected  ComponentDiscovererManager componentDiscovererManager
           
protected  ComponentFactoryManager componentFactoryManager
           
protected  ComponentLookupManager componentLookupManager
           
protected  ComponentManagerManager componentManagerManager
           
protected  ComponentRepository componentRepository
           
protected  PlexusConfiguration configuration
           
protected  java.io.Reader configurationReader
           
protected  org.codehaus.classworlds.ClassRealm containerRealm
           
protected  DefaultContext context
           
protected  java.util.Date creationDate
           
protected  java.util.List initializationPhases
           
protected  LifecycleHandlerManager lifecycleHandlerManager
           
protected  LoggerManager loggerManager
           
protected  java.lang.String name
           
protected  PlexusContainer parentContainer
           
protected  boolean reloadingEnabled
           
 
Fields inherited from interface org.codehaus.plexus.PlexusContainer
ROLE
 
Constructor Summary
DefaultPlexusContainer()
           
DefaultPlexusContainer(java.io.Reader configurationReader, java.util.Map context)
           
DefaultPlexusContainer(java.lang.String name)
           
DefaultPlexusContainer(java.lang.String name, java.lang.ClassLoader classLoader)
           
DefaultPlexusContainer(java.lang.String name, java.lang.ClassLoader classLoader, java.io.Reader configurationReader, java.util.Map context)
           
DefaultPlexusContainer(java.lang.String name, org.codehaus.classworlds.ClassWorld classWorld)
           
DefaultPlexusContainer(java.lang.String name, org.codehaus.classworlds.ClassWorld classWorld, PlexusContainer parentContainer)
           
 
Method Summary
 void addComponentDescriptor(ComponentDescriptor componentDescriptor)
           
 void addContextValue(java.lang.Object key, java.lang.Object value)
           
 void addJarRepository(java.io.File repository)
           
 void addJarResource(java.io.File jar)
           
 java.lang.Object autowire(java.lang.Object component)
           
 java.lang.Object createAndAutowire(java.lang.String clazz)
           
 PlexusContainer createChildContainer(java.lang.String name, java.util.List classpathJars, java.util.Map context)
           
 PlexusContainer createChildContainer(java.lang.String name, java.util.List classpathJars, java.util.Map context, java.util.List discoveryListeners)
           
 java.util.List discoverComponents(org.codehaus.classworlds.ClassRealm classRealm)
           
 void dispose()
           
protected  void disposeAllComponents()
           
 PlexusContainer getChildContainer(java.lang.String name)
           
 org.codehaus.classworlds.ClassWorld getClassWorld()
           
 ComponentComposerManager getComponentComposerManager()
           
 ComponentDescriptor getComponentDescriptor(java.lang.String componentKey)
           
 java.util.List getComponentDescriptorList(java.lang.String role)
           
 java.util.Map getComponentDescriptorMap(java.lang.String role)
           
 ComponentDiscovererManager getComponentDiscovererManager()
           
 ComponentFactoryManager getComponentFactoryManager()
           
 ComponentLookupManager getComponentLookupManager()
           
 ComponentManagerManager getComponentManagerManager()
           
 ComponentRepository getComponentRepository()
           
 PlexusConfiguration getConfiguration()
           
 org.codehaus.classworlds.ClassRealm getContainerRealm()
           
 Context getContext()
           
 java.util.Date getCreationDate()
           
protected  java.io.Reader getInterpolationConfigurationReader(java.io.Reader reader)
           
 LifecycleHandlerManager getLifecycleHandlerManager()
           
 Logger getLogger()
           
 LoggerManager getLoggerManager()
           
 java.lang.String getName()
           
 PlexusContainer getParentContainer()
           
 boolean hasChildContainer(java.lang.String name)
           
 boolean hasComponent(java.lang.String componentKey)
           
 boolean hasComponent(java.lang.String role, java.lang.String roleHint)
           
 void initialize()
           
protected  void initializeConfiguration()
           
 void initializePhases()
           
 boolean isReloadingEnabled()
           
 java.lang.Object lookup(java.lang.String componentKey)
           
 java.lang.Object lookup(java.lang.String role, java.lang.String roleHint)
           
 java.util.List lookupList(java.lang.String role)
           
 java.util.Map lookupMap(java.lang.String role)
           
 void registerComponentDiscoveryListener(ComponentDiscoveryListener listener)
           
 void release(java.lang.Object component)
           
 void releaseAll(java.util.List components)
           
 void releaseAll(java.util.Map components)
           
 void removeChildContainer(java.lang.String name)
           
 void removeComponentDiscoveryListener(ComponentDiscoveryListener listener)
           
 void resume(java.lang.Object component)
           
 void setClassWorld(org.codehaus.classworlds.ClassWorld classWorld)
           
 void setComponentComposerManager(ComponentComposerManager componentComposerManager)
           
 void setComponentDiscovererManager(ComponentDiscovererManager componentDiscovererManager)
           
 void setComponentFactoryManager(ComponentFactoryManager componentFactoryManager)
           
 void setComponentLookupManager(ComponentLookupManager componentLookupManager)
           
 void setComponentManagerManager(ComponentManagerManager componentManagerManager)
           
 void setComponentRepository(ComponentRepository componentRepository)
           
 void setConfiguration(PlexusConfiguration configuration)
           
 void setConfigurationResource(java.io.Reader configuration)
          //todo don't hold this reference - the reader will remain open forever
 void setContainerRealm(org.codehaus.classworlds.ClassRealm containerRealm)
           
 void setLifecycleHandlerManager(LifecycleHandlerManager lifecycleHandlerManager)
           
 void setLoggerManager(LoggerManager loggerManager)
           
 void setReloadingEnabled(boolean reloadingEnabled)
           
 void start()
           
 void suspend(java.lang.Object component)
           
 
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

name

protected java.lang.String name

parentContainer

protected PlexusContainer parentContainer

context

protected DefaultContext context

configuration

protected PlexusConfiguration configuration

configurationReader

protected java.io.Reader configurationReader

classWorld

protected org.codehaus.classworlds.ClassWorld classWorld

containerRealm

protected org.codehaus.classworlds.ClassRealm containerRealm

initializationPhases

protected java.util.List initializationPhases

componentRepository

protected ComponentRepository componentRepository

componentManagerManager

protected ComponentManagerManager componentManagerManager

lifecycleHandlerManager

protected LifecycleHandlerManager lifecycleHandlerManager

componentDiscovererManager

protected ComponentDiscovererManager componentDiscovererManager

componentFactoryManager

protected ComponentFactoryManager componentFactoryManager

componentLookupManager

protected ComponentLookupManager componentLookupManager

componentComposerManager

protected ComponentComposerManager componentComposerManager

loggerManager

protected LoggerManager loggerManager

childContainers

protected java.util.Map childContainers

creationDate

protected java.util.Date creationDate

reloadingEnabled

protected boolean reloadingEnabled
Constructor Detail

DefaultPlexusContainer

public DefaultPlexusContainer()
                       throws PlexusContainerException
Throws:
PlexusContainerException

DefaultPlexusContainer

public DefaultPlexusContainer(java.io.Reader configurationReader,
                              java.util.Map context)
                       throws PlexusContainerException
Throws:
PlexusContainerException

DefaultPlexusContainer

public DefaultPlexusContainer(java.lang.String name)
                       throws PlexusContainerException
Throws:
PlexusContainerException

DefaultPlexusContainer

public DefaultPlexusContainer(java.lang.String name,
                              java.lang.ClassLoader classLoader)
                       throws PlexusContainerException
Throws:
PlexusContainerException

DefaultPlexusContainer

public DefaultPlexusContainer(java.lang.String name,
                              java.lang.ClassLoader classLoader,
                              java.io.Reader configurationReader,
                              java.util.Map context)
                       throws PlexusContainerException
Throws:
PlexusContainerException

DefaultPlexusContainer

public DefaultPlexusContainer(java.lang.String name,
                              org.codehaus.classworlds.ClassWorld classWorld,
                              PlexusContainer parentContainer)
                       throws PlexusContainerException
Throws:
PlexusContainerException

DefaultPlexusContainer

public DefaultPlexusContainer(java.lang.String name,
                              org.codehaus.classworlds.ClassWorld classWorld)
                       throws PlexusContainerException
Throws:
PlexusContainerException
Method Detail

lookup

public java.lang.Object lookup(java.lang.String componentKey)
                        throws ComponentLookupException
Specified by:
lookup in interface PlexusContainer
Throws:
ComponentLookupException

lookupMap

public java.util.Map lookupMap(java.lang.String role)
                        throws ComponentLookupException
Specified by:
lookupMap in interface PlexusContainer
Throws:
ComponentLookupException

lookupList

public java.util.List lookupList(java.lang.String role)
                          throws ComponentLookupException
Specified by:
lookupList in interface PlexusContainer
Throws:
ComponentLookupException

lookup

public java.lang.Object lookup(java.lang.String role,
                               java.lang.String roleHint)
                        throws ComponentLookupException
Specified by:
lookup in interface PlexusContainer
Throws:
ComponentLookupException

getCreationDate

public java.util.Date getCreationDate()
Specified by:
getCreationDate in interface PlexusContainer

hasChildContainer

public boolean hasChildContainer(java.lang.String name)
Specified by:
hasChildContainer in interface PlexusContainer

removeChildContainer

public void removeChildContainer(java.lang.String name)
Specified by:
removeChildContainer in interface PlexusContainer

getChildContainer

public PlexusContainer getChildContainer(java.lang.String name)
Specified by:
getChildContainer in interface PlexusContainer

createChildContainer

public PlexusContainer createChildContainer(java.lang.String name,
                                            java.util.List classpathJars,
                                            java.util.Map context)
                                     throws PlexusContainerException
Specified by:
createChildContainer in interface PlexusContainer
Throws:
PlexusContainerException

createChildContainer

public PlexusContainer createChildContainer(java.lang.String name,
                                            java.util.List classpathJars,
                                            java.util.Map context,
                                            java.util.List discoveryListeners)
                                     throws PlexusContainerException
Specified by:
createChildContainer in interface PlexusContainer
Throws:
PlexusContainerException

getComponentDescriptor

public ComponentDescriptor getComponentDescriptor(java.lang.String componentKey)
Specified by:
getComponentDescriptor in interface PlexusContainer

getComponentDescriptorMap

public java.util.Map getComponentDescriptorMap(java.lang.String role)
Specified by:
getComponentDescriptorMap in interface PlexusContainer

getComponentDescriptorList

public java.util.List getComponentDescriptorList(java.lang.String role)
Specified by:
getComponentDescriptorList in interface PlexusContainer

addComponentDescriptor

public void addComponentDescriptor(ComponentDescriptor componentDescriptor)
                            throws ComponentRepositoryException
Specified by:
addComponentDescriptor in interface PlexusContainer
Throws:
ComponentRepositoryException

release

public void release(java.lang.Object component)
             throws ComponentLifecycleException
Specified by:
release in interface PlexusContainer
Throws:
ComponentLifecycleException

releaseAll

public void releaseAll(java.util.Map components)
                throws ComponentLifecycleException
Specified by:
releaseAll in interface PlexusContainer
Throws:
ComponentLifecycleException

releaseAll

public void releaseAll(java.util.List components)
                throws ComponentLifecycleException
Specified by:
releaseAll in interface PlexusContainer
Throws:
ComponentLifecycleException

hasComponent

public boolean hasComponent(java.lang.String componentKey)
Specified by:
hasComponent in interface PlexusContainer

hasComponent

public boolean hasComponent(java.lang.String role,
                            java.lang.String roleHint)
Specified by:
hasComponent in interface PlexusContainer

suspend

public void suspend(java.lang.Object component)
             throws ComponentLifecycleException
Specified by:
suspend in interface PlexusContainer
Throws:
ComponentLifecycleException

resume

public void resume(java.lang.Object component)
            throws ComponentLifecycleException
Specified by:
resume in interface PlexusContainer
Throws:
ComponentLifecycleException

initialize

public void initialize()
                throws PlexusContainerException
Specified by:
initialize in interface PlexusContainer
Throws:
PlexusContainerException

initializePhases

public void initializePhases()
                      throws PlexusContainerException
Throws:
PlexusContainerException

discoverComponents

public java.util.List discoverComponents(org.codehaus.classworlds.ClassRealm classRealm)
                                  throws PlexusConfigurationException,
                                         ComponentRepositoryException
Throws:
PlexusConfigurationException
ComponentRepositoryException

start

public void start()
           throws PlexusContainerException
Specified by:
start in interface PlexusContainer
Throws:
PlexusContainerException

dispose

public void dispose()
Specified by:
dispose in interface PlexusContainer

disposeAllComponents

protected void disposeAllComponents()

addContextValue

public void addContextValue(java.lang.Object key,
                            java.lang.Object value)
Specified by:
addContextValue in interface PlexusContainer

setConfigurationResource

public void setConfigurationResource(java.io.Reader configuration)
                              throws PlexusConfigurationResourceException
//todo don't hold this reference - the reader will remain open forever

Specified by:
setConfigurationResource in interface PlexusContainer
Throws:
PlexusConfigurationResourceException
See Also:
PlexusContainer.setConfigurationResource(Reader)

getName

public java.lang.String getName()
Specified by:
getName in interface PlexusContainer

getClassWorld

public org.codehaus.classworlds.ClassWorld getClassWorld()

setClassWorld

public void setClassWorld(org.codehaus.classworlds.ClassWorld classWorld)

getContainerRealm

public org.codehaus.classworlds.ClassRealm getContainerRealm()
Specified by:
getContainerRealm in interface PlexusContainer

setContainerRealm

public void setContainerRealm(org.codehaus.classworlds.ClassRealm containerRealm)

getContext

public Context getContext()
Specified by:
getContext in interface PlexusContainer

initializeConfiguration

protected void initializeConfiguration()
                                throws ConfigurationProcessingException,
                                       ConfigurationResourceNotFoundException,
                                       PlexusConfigurationException,
                                       ContextException
Throws:
ConfigurationProcessingException
ConfigurationResourceNotFoundException
PlexusConfigurationException
ContextException

getInterpolationConfigurationReader

protected java.io.Reader getInterpolationConfigurationReader(java.io.Reader reader)

addJarResource

public void addJarResource(java.io.File jar)
                    throws PlexusContainerException
Specified by:
addJarResource in interface PlexusContainer
Throws:
PlexusContainerException

addJarRepository

public void addJarRepository(java.io.File repository)
Specified by:
addJarRepository in interface PlexusContainer

getLogger

public Logger getLogger()
Specified by:
getLogger in interface MutablePlexusContainer
Specified by:
getLogger in interface PlexusContainer
Overrides:
getLogger in class AbstractLogEnabled

registerComponentDiscoveryListener

public void registerComponentDiscoveryListener(ComponentDiscoveryListener listener)
Specified by:
registerComponentDiscoveryListener in interface PlexusContainer

removeComponentDiscoveryListener

public void removeComponentDiscoveryListener(ComponentDiscoveryListener listener)
Specified by:
removeComponentDiscoveryListener in interface PlexusContainer

autowire

public java.lang.Object autowire(java.lang.Object component)
                          throws CompositionException
Specified by:
autowire in interface PlexusContainer
Throws:
CompositionException

createAndAutowire

public java.lang.Object createAndAutowire(java.lang.String clazz)
                                   throws CompositionException,
                                          java.lang.ClassNotFoundException,
                                          java.lang.InstantiationException,
                                          java.lang.IllegalAccessException
Specified by:
createAndAutowire in interface PlexusContainer
Throws:
CompositionException
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException

setReloadingEnabled

public void setReloadingEnabled(boolean reloadingEnabled)
Specified by:
setReloadingEnabled in interface PlexusContainer

isReloadingEnabled

public boolean isReloadingEnabled()
Specified by:
isReloadingEnabled in interface PlexusContainer

getComponentRepository

public ComponentRepository getComponentRepository()
Specified by:
getComponentRepository in interface MutablePlexusContainer

setComponentRepository

public void setComponentRepository(ComponentRepository componentRepository)
Specified by:
setComponentRepository in interface MutablePlexusContainer

getComponentManagerManager

public ComponentManagerManager getComponentManagerManager()
Specified by:
getComponentManagerManager in interface MutablePlexusContainer

setComponentManagerManager

public void setComponentManagerManager(ComponentManagerManager componentManagerManager)
Specified by:
setComponentManagerManager in interface MutablePlexusContainer

getLifecycleHandlerManager

public LifecycleHandlerManager getLifecycleHandlerManager()
Specified by:
getLifecycleHandlerManager in interface MutablePlexusContainer

setLifecycleHandlerManager

public void setLifecycleHandlerManager(LifecycleHandlerManager lifecycleHandlerManager)
Specified by:
setLifecycleHandlerManager in interface MutablePlexusContainer

getComponentDiscovererManager

public ComponentDiscovererManager getComponentDiscovererManager()
Specified by:
getComponentDiscovererManager in interface MutablePlexusContainer

setComponentDiscovererManager

public void setComponentDiscovererManager(ComponentDiscovererManager componentDiscovererManager)
Specified by:
setComponentDiscovererManager in interface MutablePlexusContainer

getComponentFactoryManager

public ComponentFactoryManager getComponentFactoryManager()
Specified by:
getComponentFactoryManager in interface MutablePlexusContainer

setComponentFactoryManager

public void setComponentFactoryManager(ComponentFactoryManager componentFactoryManager)
Specified by:
setComponentFactoryManager in interface MutablePlexusContainer

getComponentLookupManager

public ComponentLookupManager getComponentLookupManager()
Specified by:
getComponentLookupManager in interface MutablePlexusContainer

setComponentLookupManager

public void setComponentLookupManager(ComponentLookupManager componentLookupManager)
Specified by:
setComponentLookupManager in interface MutablePlexusContainer

getComponentComposerManager

public ComponentComposerManager getComponentComposerManager()
Specified by:
getComponentComposerManager in interface MutablePlexusContainer

setComponentComposerManager

public void setComponentComposerManager(ComponentComposerManager componentComposerManager)
Specified by:
setComponentComposerManager in interface MutablePlexusContainer

getLoggerManager

public LoggerManager getLoggerManager()
Specified by:
getLoggerManager in interface MutablePlexusContainer
Specified by:
getLoggerManager in interface PlexusContainer

setLoggerManager

public void setLoggerManager(LoggerManager loggerManager)
Specified by:
setLoggerManager in interface MutablePlexusContainer

getConfiguration

public PlexusConfiguration getConfiguration()
Specified by:
getConfiguration in interface MutablePlexusContainer

setConfiguration

public void setConfiguration(PlexusConfiguration configuration)
Specified by:
setConfiguration in interface MutablePlexusContainer

getParentContainer

public PlexusContainer getParentContainer()
Specified by:
getParentContainer in interface MutablePlexusContainer


Copyright © 2001-2006 Codehaus. All Rights Reserved.