|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.picocontainer.extras.DefaultLifecyclePicoContainer
Constructor Summary | |
DefaultLifecyclePicoContainer()
|
|
DefaultLifecyclePicoContainer(LifecyclePicoAdapter lifecyclePicoAdapter,
MutablePicoContainer mutablePicoContainer)
|
|
DefaultLifecyclePicoContainer(MutablePicoContainer mutablePicoContainer)
|
Method Summary | |
void |
addChild(MutablePicoContainer child)
Adds a Child container. |
void |
addOrderedComponentAdapter(ComponentAdapter componentAdapter)
Adds a component instance to the container. |
void |
addParent(MutablePicoContainer parent)
Adds a Parent container. |
void |
dispose()
|
ComponentAdapter |
findComponentAdapter(Object componentKey)
Finds a ComponentAdapter matching the key. |
Collection |
getChildContainers()
Get the child containers of this container. |
Object |
getComponentInstance(Object componentKey)
Gets a component instance. |
List |
getComponentInstances()
Gets all the registered component instances in the container. |
Collection |
getComponentKeys()
Get all the component keys. |
Object |
getComponentMulticaster()
Shorthand for getComponentMulticaster(boolean, boolean) |
Object |
getComponentMulticaster(boolean callInInstantiationOrder,
boolean callUnmanagedComponents)
Returns an object (in fact, a dynamic proxy) that implements the union of all the interfaces of the currently registered components. |
List |
getParentContainers()
Get the parent containers of this container. |
PicoContainer |
getPicoContainer()
|
boolean |
hasComponent(Object componentKey)
Checks for the presence of a particular component. |
boolean |
isDisposed()
|
boolean |
isStarted()
|
boolean |
isStopped()
|
Object |
registerComponentImplementation(Class componentImplementation)
Registers a component using the componentImplementation as key. |
Object |
registerComponentImplementation(Object componentKey,
Class componentImplementation)
Registers a component. |
Object |
registerComponentImplementation(Object componentKey,
Class componentImplementation,
Parameter[] parameters)
Registers a component. |
Object |
registerComponentInstance(Object componentInstance)
Registers an arbitrary object, using itself as a key. |
Object |
registerComponentInstance(Object componentKey,
Object componentInstance)
Registers an arbitrary object as a compoent in the container. |
void |
start()
|
void |
stop()
|
Object |
unregisterComponent(Object componentKey)
Unregisters a component. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DefaultLifecyclePicoContainer(LifecyclePicoAdapter lifecyclePicoAdapter, MutablePicoContainer mutablePicoContainer)
public DefaultLifecyclePicoContainer(MutablePicoContainer mutablePicoContainer)
public DefaultLifecyclePicoContainer()
Method Detail |
public ComponentAdapter findComponentAdapter(Object componentKey) throws PicoIntrospectionException
PicoContainer
findComponentAdapter
in interface PicoContainer
componentKey
- key of the component.
PicoIntrospectionException
public void dispose()
dispose
in interface Disposable
public void start()
start
in interface Startable
public PicoContainer getPicoContainer()
getPicoContainer
in interface LifecyclePicoAdapter
public boolean isStarted()
isStarted
in interface LifecyclePicoAdapter
public Object getComponentInstance(Object componentKey) throws PicoException
PicoContainer
getComponentInstance
in interface PicoContainer
componentKey
- key the component was registered with.
PicoException
- if the component could not be instantiated or dependencies
could not be properly resolved.public Collection getChildContainers()
PicoContainer
getChildContainers
in interface PicoContainer
PicoContainer
.PicoContainer.getParentContainers()
public void stop()
stop
in interface Stoppable
public boolean isDisposed()
isDisposed
in interface LifecyclePicoAdapter
public Object getComponentMulticaster() throws PicoException
PicoContainer
PicoContainer.getComponentMulticaster(boolean, boolean)
(true, false), which is the most common usage scenario.
getComponentMulticaster
in interface PicoContainer
PicoException
public Collection getComponentKeys()
PicoContainer
getComponentKeys
in interface PicoContainer
public boolean isStopped()
isStopped
in interface LifecyclePicoAdapter
public boolean hasComponent(Object componentKey)
PicoContainer
hasComponent
in interface PicoContainer
componentKey
- key of the component to look for.
public List getComponentInstances() throws PicoException
PicoContainer
getComponentInstances
in interface PicoContainer
PicoException
- if one of the components could not be instantiated or dependencies
could not be properly resolved.public Object getComponentMulticaster(boolean callInInstantiationOrder, boolean callUnmanagedComponents) throws PicoException
PicoContainer
Casting this object to any of those interfaces and then calling a method on it will result in that call being multicast to all the components implementing that given interface.
This is a simple yet extremely powerful way to handle lifecycle of components. Component writers can invent their own lifecycle interfaces, and then use the multicaster to invoke the method in one go.
getComponentMulticaster
in interface PicoContainer
callInInstantiationOrder
- whether or not to call the method in the order of instantiation,
which depends on the components' inter-dependencies.callUnmanagedComponents
- whether or not to multicast to components that are not managed
by this container.
PicoException
public List getParentContainers()
PicoContainer
getParentContainers
in interface PicoContainer
PicoContainer
.public Object unregisterComponent(Object componentKey)
MutablePicoContainer
unregisterComponent
in interface MutablePicoContainer
componentKey
- key of the component to unregister.
public Object registerComponentInstance(Object componentKey, Object componentInstance) throws PicoRegistrationException
MutablePicoContainer
registerComponentInstance
in interface MutablePicoContainer
componentKey
- a key that identifies the compoent. Must be unique within the conainer.componentInstance
- an arbitrary object.
PicoRegistrationException
- if registration fails.public void addChild(MutablePicoContainer child)
MutablePicoContainer
MutablePicoContainer.addParent(org.picocontainer.MutablePicoContainer)
is not necessary.
addChild
in interface MutablePicoContainer
child
- child container.public void addParent(MutablePicoContainer parent)
MutablePicoContainer
MutablePicoContainer.addChild(org.picocontainer.MutablePicoContainer)
is not necessary.
addParent
in interface MutablePicoContainer
parent
- parent container.public Object registerComponentImplementation(Object componentKey, Class componentImplementation) throws PicoRegistrationException
MutablePicoContainer
registerComponentImplementation
in interface MutablePicoContainer
componentKey
- a key that identifies the compoent. Must be unique within the conainer.componentImplementation
- the concrete component class.
PicoRegistrationException
- if registration fails.public Object registerComponentInstance(Object componentInstance) throws PicoRegistrationException
MutablePicoContainer
registerComponentInstance
in interface MutablePicoContainer
componentInstance
-
PicoRegistrationException
public void addOrderedComponentAdapter(ComponentAdapter componentAdapter)
MutablePicoContainer
MutablePicoContainer.registerComponentInstance(java.lang.Object)
instead if you wish to register externally instantiated objects.
addOrderedComponentAdapter
in interface MutablePicoContainer
componentAdapter
- key of the component.public Object registerComponentImplementation(Class componentImplementation) throws PicoRegistrationException
MutablePicoContainer
registerComponentImplementation
in interface MutablePicoContainer
componentImplementation
- the concrete component class.
PicoRegistrationException
- if registration fails.public Object registerComponentImplementation(Object componentKey, Class componentImplementation, Parameter[] parameters) throws PicoRegistrationException
MutablePicoContainer
registerComponentImplementation
in interface MutablePicoContainer
componentKey
- a key that identifies the compoent. Must be unique within the conainer.componentImplementation
- the concrete component class.parameters
- an array of parameters that gives the container hints about what arguments
to pass to the constructor when it is instantiated.
PicoRegistrationException
- if registration fails.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |