eXo Kernel :: Container 2.4.11-UXP01

org.exoplatform.container
Class ConcurrentPicoContainer

java.lang.Object
  extended by org.exoplatform.container.ConcurrentPicoContainer
All Implemented Interfaces:
Serializable, org.picocontainer.Disposable, org.picocontainer.MutablePicoContainer, org.picocontainer.PicoContainer, org.picocontainer.Startable
Direct Known Subclasses:
MCIntegrationContainer

public class ConcurrentPicoContainer
extends Object
implements org.picocontainer.MutablePicoContainer, Serializable

This class is aimed to be the ThreadSafe counterpart of DefaultPicoContainer based on java.util.concurrent collections. Created by The eXo Platform SAS Author : Nicolas Filotto nicolas.filotto@exoplatform.com 6 mai 2010

Version:
$Revision$
See Also:
Serialized Form

Nested Class Summary
protected static class ConcurrentPicoContainer.ContainerVisitor
          Cans be used to indicate that we only want to visit Containers
 
Field Summary
protected  org.picocontainer.defaults.ComponentAdapterFactory componentAdapterFactory
           
 
Constructor Summary
ConcurrentPicoContainer()
          Creates a new container with a (caching) DefaultComponentAdapterFactory and no parent container.
ConcurrentPicoContainer(org.picocontainer.defaults.ComponentAdapterFactory componentAdapterFactory)
          Creates a new container with a custom ComponentAdapterFactory and no parent container.
ConcurrentPicoContainer(org.picocontainer.defaults.ComponentAdapterFactory componentAdapterFactory, org.picocontainer.PicoContainer parent)
          Creates a new container with a custom ComponentAdapterFactory and a parent container.
ConcurrentPicoContainer(org.picocontainer.PicoContainer parent)
          Creates a new container with a (caching) DefaultComponentAdapterFactory and a parent container.
 
Method Summary
protected  void accept(ConcurrentPicoContainer.ContainerVisitor visitor)
          Accepts a visitor that should visit the child containers only.
 void accept(org.picocontainer.PicoVisitor visitor)
           
 boolean addChildContainer(org.picocontainer.PicoContainer child)
           
 void addComponentToCtx(Object key, Object component)
          Add the component corresponding to the given key, to the dependency resolution context
protected  boolean canBeDisposed()
          Indicates whether or not the container can be disposed
protected  boolean canBeStarted()
          Indicates whether or not the container can be started
protected  boolean canBeStopped()
          Indicates whether or not the container can be stopped
 void dispose()
          Dispose the components of this PicoContainer and all its logical child containers.
 org.picocontainer.ComponentAdapter getComponentAdapter(Object componentKey)
           
 org.picocontainer.ComponentAdapter getComponentAdapterOfType(Class componentType)
           
 Collection getComponentAdapters()
           
 List getComponentAdaptersOfType(Class componentType)
           
 Object getComponentInstance(Object componentKey)
           
 Object getComponentInstanceOfType(Class componentType)
          If no ComponentAdapter can be found it returns null otherwise it first try to get it from the dependency resolution context if it still cannot be found we get the instance from the ComponentAdapter.
 List getComponentInstances()
           
 List getComponentInstancesOfType(Class componentType)
           
 org.picocontainer.PicoContainer getParent()
           
 org.picocontainer.MutablePicoContainer makeChildContainer()
           
 org.picocontainer.ComponentAdapter registerComponent(org.picocontainer.ComponentAdapter componentAdapter)
           This method can be used to override the ComponentAdapter created by the ComponentAdapterFactory passed to the constructor of this container.
 org.picocontainer.ComponentAdapter registerComponentImplementation(Class componentImplementation)
           The returned ComponentAdapter will be instantiated by the ComponentAdapterFactory passed to the container's constructor.
 org.picocontainer.ComponentAdapter registerComponentImplementation(Object componentKey, Class componentImplementation)
           The returned ComponentAdapter will be instantiated by the ComponentAdapterFactory passed to the container's constructor.
 org.picocontainer.ComponentAdapter registerComponentImplementation(Object componentKey, Class componentImplementation, List parameters)
          Same as registerComponentImplementation(java.lang.Object, java.lang.Class, org.picocontainer.Parameter[]) but with parameters as a List.
 org.picocontainer.ComponentAdapter registerComponentImplementation(Object componentKey, Class componentImplementation, org.picocontainer.Parameter[] parameters)
           The returned ComponentAdapter will be instantiated by the ComponentAdapterFactory passed to the container's constructor.
 org.picocontainer.ComponentAdapter registerComponentInstance(Object component)
           The returned ComponentAdapter will be an InstanceComponentAdapter.
 org.picocontainer.ComponentAdapter registerComponentInstance(Object componentKey, Object componentInstance)
           The returned ComponentAdapter will be an InstanceComponentAdapter.
 boolean removeChildContainer(org.picocontainer.PicoContainer child)
           
 void removeComponentFromCtx(Object key)
          Remove the component corresponding to the given key, from the dependency resolution context
 void start()
          Start the components of this PicoContainer and all its logical child containers.
 void stop()
          Stop the components of this PicoContainer and all its logical child containers.
 org.picocontainer.ComponentAdapter unregisterComponent(Object componentKey)
           
 org.picocontainer.ComponentAdapter unregisterComponentByInstance(Object componentInstance)
           
 void verify()
          Deprecated. since 1.1 - Use new VerifyingVisitor().traverse(this)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

componentAdapterFactory

protected final org.picocontainer.defaults.ComponentAdapterFactory componentAdapterFactory
Constructor Detail

ConcurrentPicoContainer

public ConcurrentPicoContainer(org.picocontainer.defaults.ComponentAdapterFactory componentAdapterFactory,
                               org.picocontainer.PicoContainer parent)
Creates a new container with a custom ComponentAdapterFactory and a parent container.

Important note about caching: If you intend the components to be cached, you should pass in a factory that creates CachingComponentAdapter instances, such as for example CachingComponentAdapterFactory. CachingComponentAdapterFactory can delegate to other ComponentAdapterFactories.

Parameters:
componentAdapterFactory - the factory to use for creation of ComponentAdapters.
parent - the parent container (used for component dependency lookups).

ConcurrentPicoContainer

public ConcurrentPicoContainer(org.picocontainer.PicoContainer parent)
Creates a new container with a (caching) DefaultComponentAdapterFactory and a parent container.


ConcurrentPicoContainer

public ConcurrentPicoContainer(org.picocontainer.defaults.ComponentAdapterFactory componentAdapterFactory)
Creates a new container with a custom ComponentAdapterFactory and no parent container.

Parameters:
componentAdapterFactory - the ComponentAdapterFactory to use.

ConcurrentPicoContainer

public ConcurrentPicoContainer()
Creates a new container with a (caching) DefaultComponentAdapterFactory and no parent container.

Method Detail

getComponentAdapters

public Collection getComponentAdapters()
Specified by:
getComponentAdapters in interface org.picocontainer.PicoContainer

getComponentAdapter

public final org.picocontainer.ComponentAdapter getComponentAdapter(Object componentKey)
                                                             throws org.picocontainer.defaults.AmbiguousComponentResolutionException
Specified by:
getComponentAdapter in interface org.picocontainer.PicoContainer
Throws:
org.picocontainer.defaults.AmbiguousComponentResolutionException

getComponentAdapterOfType

public org.picocontainer.ComponentAdapter getComponentAdapterOfType(Class componentType)
Specified by:
getComponentAdapterOfType in interface org.picocontainer.PicoContainer

getComponentAdaptersOfType

public List getComponentAdaptersOfType(Class componentType)
Specified by:
getComponentAdaptersOfType in interface org.picocontainer.PicoContainer

registerComponent

public org.picocontainer.ComponentAdapter registerComponent(org.picocontainer.ComponentAdapter componentAdapter)
                                                     throws org.picocontainer.defaults.DuplicateComponentKeyRegistrationException
This method can be used to override the ComponentAdapter created by the ComponentAdapterFactory passed to the constructor of this container.

Specified by:
registerComponent in interface org.picocontainer.MutablePicoContainer
Throws:
org.picocontainer.defaults.DuplicateComponentKeyRegistrationException

unregisterComponent

public org.picocontainer.ComponentAdapter unregisterComponent(Object componentKey)
Specified by:
unregisterComponent in interface org.picocontainer.MutablePicoContainer

registerComponentInstance

public org.picocontainer.ComponentAdapter registerComponentInstance(Object component)
                                                             throws org.picocontainer.PicoRegistrationException
The returned ComponentAdapter will be an InstanceComponentAdapter.

Specified by:
registerComponentInstance in interface org.picocontainer.MutablePicoContainer
Throws:
org.picocontainer.PicoRegistrationException

registerComponentInstance

public org.picocontainer.ComponentAdapter registerComponentInstance(Object componentKey,
                                                                    Object componentInstance)
                                                             throws org.picocontainer.PicoRegistrationException
The returned ComponentAdapter will be an InstanceComponentAdapter.

Specified by:
registerComponentInstance in interface org.picocontainer.MutablePicoContainer
Throws:
org.picocontainer.PicoRegistrationException

registerComponentImplementation

public org.picocontainer.ComponentAdapter registerComponentImplementation(Class componentImplementation)
                                                                   throws org.picocontainer.PicoRegistrationException
The returned ComponentAdapter will be instantiated by the ComponentAdapterFactory passed to the container's constructor.

Specified by:
registerComponentImplementation in interface org.picocontainer.MutablePicoContainer
Throws:
org.picocontainer.PicoRegistrationException

registerComponentImplementation

public org.picocontainer.ComponentAdapter registerComponentImplementation(Object componentKey,
                                                                          Class componentImplementation)
                                                                   throws org.picocontainer.PicoRegistrationException
The returned ComponentAdapter will be instantiated by the ComponentAdapterFactory passed to the container's constructor.

Specified by:
registerComponentImplementation in interface org.picocontainer.MutablePicoContainer
Throws:
org.picocontainer.PicoRegistrationException

registerComponentImplementation

public org.picocontainer.ComponentAdapter registerComponentImplementation(Object componentKey,
                                                                          Class componentImplementation,
                                                                          org.picocontainer.Parameter[] parameters)
                                                                   throws org.picocontainer.PicoRegistrationException
The returned ComponentAdapter will be instantiated by the ComponentAdapterFactory passed to the container's constructor.

Specified by:
registerComponentImplementation in interface org.picocontainer.MutablePicoContainer
Throws:
org.picocontainer.PicoRegistrationException

registerComponentImplementation

public org.picocontainer.ComponentAdapter registerComponentImplementation(Object componentKey,
                                                                          Class componentImplementation,
                                                                          List parameters)
                                                                   throws org.picocontainer.PicoRegistrationException
Same as registerComponentImplementation(java.lang.Object, java.lang.Class, org.picocontainer.Parameter[]) but with parameters as a List. Makes it possible to use with Groovy arrays (which are actually Lists).

Throws:
org.picocontainer.PicoRegistrationException

getComponentInstances

public List getComponentInstances()
                           throws org.picocontainer.PicoException
Specified by:
getComponentInstances in interface org.picocontainer.PicoContainer
Throws:
org.picocontainer.PicoException

getComponentInstancesOfType

public List getComponentInstancesOfType(Class componentType)
                                 throws org.picocontainer.PicoException
Specified by:
getComponentInstancesOfType in interface org.picocontainer.PicoContainer
Throws:
org.picocontainer.PicoException

getComponentInstance

public Object getComponentInstance(Object componentKey)
                            throws org.picocontainer.PicoException
Specified by:
getComponentInstance in interface org.picocontainer.PicoContainer
Throws:
org.picocontainer.PicoException

getComponentInstanceOfType

public Object getComponentInstanceOfType(Class componentType)
If no ComponentAdapter can be found it returns null otherwise it first try to get it from the dependency resolution context if it still cannot be found we get the instance from the ComponentAdapter.

Specified by:
getComponentInstanceOfType in interface org.picocontainer.PicoContainer
See Also:
PicoContainer.getComponentInstanceOfType(java.lang.Class)

addComponentToCtx

public void addComponentToCtx(Object key,
                              Object component)
Add the component corresponding to the given key, to the dependency resolution context

Parameters:
key - The key of the component to add to the context
component - The instance of the component to add to the context

removeComponentFromCtx

public void removeComponentFromCtx(Object key)
Remove the component corresponding to the given key, from the dependency resolution context

Parameters:
key - The key of the component to remove from the context

getParent

public org.picocontainer.PicoContainer getParent()
Specified by:
getParent in interface org.picocontainer.PicoContainer

unregisterComponentByInstance

public org.picocontainer.ComponentAdapter unregisterComponentByInstance(Object componentInstance)
Specified by:
unregisterComponentByInstance in interface org.picocontainer.MutablePicoContainer

verify

public void verify()
            throws org.picocontainer.PicoVerificationException
Deprecated. since 1.1 - Use new VerifyingVisitor().traverse(this)

Specified by:
verify in interface org.picocontainer.PicoContainer
Throws:
org.picocontainer.PicoVerificationException

canBeStarted

protected boolean canBeStarted()
Indicates whether or not the container can be started


canBeStopped

protected boolean canBeStopped()
Indicates whether or not the container can be stopped


canBeDisposed

protected boolean canBeDisposed()
Indicates whether or not the container can be disposed


start

public void start()
Start the components of this PicoContainer and all its logical child containers. Any component implementing the lifecycle interface Startable will be started.

Specified by:
start in interface org.picocontainer.Startable
See Also:
makeChildContainer(), addChildContainer(PicoContainer), removeChildContainer(PicoContainer)

stop

public void stop()
Stop the components of this PicoContainer and all its logical child containers. Any component implementing the lifecycle interface Startable will be stopped.

Specified by:
stop in interface org.picocontainer.Startable
See Also:
makeChildContainer(), addChildContainer(PicoContainer), removeChildContainer(PicoContainer)

dispose

public void dispose()
Dispose the components of this PicoContainer and all its logical child containers. Any component implementing the lifecycle interface Disposable will be disposed.

Specified by:
dispose in interface org.picocontainer.Disposable
See Also:
makeChildContainer(), addChildContainer(PicoContainer), removeChildContainer(PicoContainer)

makeChildContainer

public org.picocontainer.MutablePicoContainer makeChildContainer()
Specified by:
makeChildContainer in interface org.picocontainer.MutablePicoContainer

addChildContainer

public boolean addChildContainer(org.picocontainer.PicoContainer child)
Specified by:
addChildContainer in interface org.picocontainer.MutablePicoContainer

removeChildContainer

public boolean removeChildContainer(org.picocontainer.PicoContainer child)
Specified by:
removeChildContainer in interface org.picocontainer.MutablePicoContainer

accept

public void accept(org.picocontainer.PicoVisitor visitor)
Specified by:
accept in interface org.picocontainer.PicoContainer

accept

protected void accept(ConcurrentPicoContainer.ContainerVisitor visitor)
Accepts a visitor that should visit the child containers only.


eXo Kernel :: Container 2.4.11-UXP01

Copyright © 2014 eXo Platform SAS. All Rights Reserved.