org.picocontainer.extras
Class CompositePicoContainer

java.lang.Object
  extended byorg.picocontainer.extras.CompositePicoContainer
All Implemented Interfaces:
PicoContainer, Serializable
Direct Known Subclasses:
CompositePicoContainer.Default, CompositePicoContainer.WithContainerArray

public class CompositePicoContainer
extends Object
implements PicoContainer, Serializable

CompositePicoContainer aggregates the the contents of more than one internals together for the sake of a single list of components. This list may be used as the parent internals for another PicoContainer. This will result in directive graphs of containers/components rather than just trees. It is not in itself, a Pico component (the array in the constructor puts paid to that).

See Also:
Serialized Form

Nested Class Summary
static class CompositePicoContainer.Default
           
static class CompositePicoContainer.WithContainerArray
           
 
Constructor Summary
CompositePicoContainer(ComponentRegistry componentRegistry, PicoContainer[] containers)
           
 
Method Summary
protected  void addContainer(PicoContainer container)
          Adds a new Pico internals to this composite internals
 Object getComponent(Object componentKey)
          Get a component for a component type.
 Collection getComponentKeys()
          Get all component types (random order).
 Object getComponentMulticaster()
          Shorthand for getComponentMulticaster(boolean, boolean)(true, true).
 Object getComponentMulticaster(boolean callInInstantiationOrder, boolean callUnmanagedComponents)
          Returns a proxy that implements the union of all the components' interfaces.
 Collection getComponents()
          Get all components (random order).
 boolean hasComponent(Object componentKey)
          Does the internals have a partilcilar component type?
 void instantiateComponents()
          Initialize the internals.
protected  void removeContainer(PicoContainer container)
          Removes a Pico internals from this composite internals
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositePicoContainer

public CompositePicoContainer(ComponentRegistry componentRegistry,
                              PicoContainer[] containers)
Method Detail

getComponent

public Object getComponent(Object componentKey)
Description copied from interface: PicoContainer
Get a component for a component type.

Specified by:
getComponent in interface PicoContainer
Parameters:
componentKey - The component type to look for.
Returns:
the component, or null of no such component.

getComponentKeys

public Collection getComponentKeys()
Description copied from interface: PicoContainer
Get all component types (random order).

Specified by:
getComponentKeys in interface PicoContainer
Returns:
A collection of component types.

instantiateComponents

public void instantiateComponents()
Description copied from interface: PicoContainer
Initialize the internals.

Specified by:
instantiateComponents in interface PicoContainer

hasComponent

public boolean hasComponent(Object componentKey)
Description copied from interface: PicoContainer
Does the internals have a partilcilar component type?

Specified by:
hasComponent in interface PicoContainer
Parameters:
componentKey - The component type to look for.
Returns:
true if it does have the component type

getComponents

public Collection getComponents()
Description copied from interface: PicoContainer
Get all components (random order).

Specified by:
getComponents in interface PicoContainer
Returns:
A collection of components.

getComponentMulticaster

public Object getComponentMulticaster()
Description copied from interface: PicoContainer
Shorthand for PicoContainer.getComponentMulticaster(boolean, boolean)(true, true).

Specified by:
getComponentMulticaster in interface PicoContainer
Returns:
a proxy.

getComponentMulticaster

public Object getComponentMulticaster(boolean callInInstantiationOrder,
                                      boolean callUnmanagedComponents)
Description copied from interface: PicoContainer
Returns a proxy that implements the union of all the components' interfaces. Calling a method on the returned Object will call the method on all components in the internals that implement that interface.

Specified by:
getComponentMulticaster in interface PicoContainer
Parameters:
callInInstantiationOrder - whether to call the methods in the order of instantiation (true) or reverse (false)
callUnmanagedComponents - whether to exclude components registered via instance rather than class

addContainer

protected void addContainer(PicoContainer container)
Adds a new Pico internals to this composite internals

Parameters:
container -

removeContainer

protected void removeContainer(PicoContainer container)
Removes a Pico internals from this composite internals

Parameters:
container -


Copyright © 2003 Codehaus. All Rights Reserved.