public abstract class AbstractDelegatingMutablePicoContainer extends AbstractDelegatingPicoContainer implements MutablePicoContainer
| Constructor and Description |
|---|
AbstractDelegatingMutablePicoContainer(MutablePicoContainer delegate) |
| Modifier and Type | Method and Description |
|---|---|
MutablePicoContainer |
addAdapter(ComponentAdapter<?> componentAdapter)
Register a component via a ComponentAdapter.
|
MutablePicoContainer |
addChildContainer(PicoContainer child)
Add a child container.
|
MutablePicoContainer |
addComponent(Object implOrInstance)
Register an arbitrary object.
|
MutablePicoContainer |
addComponent(Object componentKey,
Object componentImplementationOrInstance,
Parameter... parameters)
Register a component and creates specific instructions on which constructor to use, along with
which components and/or constants to provide as constructor arguments.
|
MutablePicoContainer |
addConfig(String name,
Object val)
Register a config item.
|
MutablePicoContainer |
as(Properties... properties)
You can set for the following operation only the characteristic of registration of a component on the fly.
|
MutablePicoContainer |
change(Properties... properties)
You can change the characteristic of registration of all subsequent components in this container.
|
void |
dispose()
Dispose this component.
|
MutablePicoContainer |
getDelegate() |
LifecycleState |
getLifecycleState()
Allow querying of the current lifecycle state of a MutablePicoContainer.
|
String |
getName()
Retrieve the name set (if any).
|
MutablePicoContainer |
makeChildContainer()
Make a child container, using both the same implementation of MutablePicoContainer as the parent
and identical behaviors as well.
|
boolean |
removeChildContainer(PicoContainer child)
Remove a child container from this container.
|
<T> ComponentAdapter<T> |
removeComponent(Object componentKey)
Unregister a component by key.
|
<T> ComponentAdapter<T> |
removeComponentByInstance(T componentInstance)
Unregister a component by instance.
|
void |
setLifecycleState(LifecycleState lifecycleState)
To assist ThreadLocal usage, LifecycleState can be set.
|
void |
setName(String name)
Name the container instance, to assist debugging or other indexing.
|
void |
start()
Start this component.
|
void |
stop()
Stop this component.
|
accept, equals, getComponent, getComponent, getComponent, getComponent, getComponentAdapter, getComponentAdapter, getComponentAdapter, getComponentAdapters, getComponentAdapters, getComponentAdapters, getComponents, getComponents, getConverters, getParent, toStringclone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaccept, getComponent, getComponent, getComponent, getComponent, getComponentAdapter, getComponentAdapter, getComponentAdapter, getComponentAdapters, getComponentAdapters, getComponentAdapters, getComponents, getComponents, getParentpublic AbstractDelegatingMutablePicoContainer(MutablePicoContainer delegate)
public MutablePicoContainer addComponent(Object componentKey, Object componentImplementationOrInstance, Parameter... parameters) throws PicoCompositionException
MutablePicoContainernew ComponentParameter(), new ComponentParameter("someService")
The default constructor for the component parameter indicates auto-wiring should take place for
that parameter.
new Parameter[0]
addComponent in interface MutablePicoContainercomponentKey - a key that identifies the component. Must be unique within the container. The type
of the key object has no semantic significance unless explicitly specified in the
documentation of the implementing container.componentImplementationOrInstance - the component's implementation class. This must be a concrete class (ie, a
class that can be instantiated). Or an intance of the compoent.parameters - the parameters that gives the container hints about what arguments to pass
to the constructor when it is instantiated. Container implementations may ignore
one or more of these hints.PicoCompositionException - if registration of the component fails.Parameter,
ConstantParameter,
ComponentParameterpublic MutablePicoContainer addComponent(Object implOrInstance) throws PicoCompositionException
MutablePicoContaineraddComponent(componentImplementation, componentImplementation).addComponent in interface MutablePicoContainerimplOrInstance - Component implementation or instancePicoCompositionException - if registration fails.public MutablePicoContainer addConfig(String name, Object val)
MutablePicoContaineraddConfig in interface MutablePicoContainername - the name of the config itemval - the value of the config itempublic MutablePicoContainer addAdapter(ComponentAdapter<?> componentAdapter) throws PicoCompositionException
MutablePicoContaineraddAdapter in interface MutablePicoContainercomponentAdapter - the adapterPicoCompositionException - if registration fails.public <T> ComponentAdapter<T> removeComponent(Object componentKey)
MutablePicoContainerremoveComponent in interface MutablePicoContainercomponentKey - key of the component to unregister.public <T> ComponentAdapter<T> removeComponentByInstance(T componentInstance)
MutablePicoContainerremoveComponentByInstance in interface MutablePicoContainercomponentInstance - the component instance to unregister.public MutablePicoContainer addChildContainer(PicoContainer child)
MutablePicoContaineraddChildContainer in interface MutablePicoContainerchild - the child containerpublic boolean removeChildContainer(PicoContainer child)
MutablePicoContainerremoveChildContainer in interface MutablePicoContainerchild - the child containertrue if the child container has been removed.public MutablePicoContainer change(Properties... properties)
MutablePicoContainerchange in interface MutablePicoContainerpublic MutablePicoContainer as(Properties... properties)
MutablePicoContaineras in interface MutablePicoContainerpublic void dispose()
Disposabledispose in interface Disposablepublic MutablePicoContainer makeChildContainer()
MutablePicoContainerNote that for long-lived parent containers, you need to unregister child containers made with this call before disposing or you will leak memory. (Experience speaking here! )
Incorrect Example:
MutablePicoContainer parent = new PicoBuilder().withCaching().withLifecycle().build(); MutablePicoContainer child = parent.makeChildContainer(); child = null; //Child still retains in memory because parent still holds reference.
Correct Example:
MutablePicoContainer parent = new PicoBuilder().withCaching().withLifecycle().build(); MutablePicoContainer child = parent.makeChildContainer(); parent.removeChildContainer(child); //Remove the bi-directional references. child = null;
makeChildContainer in interface MutablePicoContainerpublic void start()
Startablepublic void stop()
StartableDisposable if you need a single call at the definite end of the lifecycle.public MutablePicoContainer getDelegate()
getDelegate in class AbstractDelegatingPicoContainerpublic void setName(String name)
MutablePicoContainersetName in interface MutablePicoContainername - the name to call it.public void setLifecycleState(LifecycleState lifecycleState)
MutablePicoContainersetLifecycleState in interface MutablePicoContainerlifecycleState - the lifecyle state to use.public LifecycleState getLifecycleState()
getLifecycleState in interface MutablePicoContainerpublic String getName()
getName in interface MutablePicoContainersetName.Copyright © 2003-2014 Codehaus. All Rights Reserved.