picocontainer.defaults
Class DefaultPicoContainer

java.lang.Object
  extended bypicocontainer.defaults.DefaultPicoContainer
All Implemented Interfaces:
PicoContainer
Direct Known Subclasses:
AggregatedContainersContainer, DefaultPicoContainer.Default, HierarchicalPicoContainer

public class DefaultPicoContainer
extends Object
implements PicoContainer

Abstract baseclass for various PicoContainer implementations.

Version:
$Revision: 1.8 $
Author:
Aslak Hellesoy

Nested Class Summary
static class DefaultPicoContainer.Default
           
 
Field Summary
protected  List orderedComponents
           
protected  List unmanagedComponents
           
 
Constructor Summary
DefaultPicoContainer(ComponentFactory componentFactory)
           
 
Method Summary
 void addParameterToComponent(Class componentType, Class parameter, Object arg)
           
 Object getAggregateComponentProxy(boolean callInInstantiationOrder, boolean callUnmanagedComponents)
          Returns a proxy that implements the union of all the components' interfaces.
 Object getComponent(Class componentType)
          Get a component for a component type.
protected  Object getComponentForParam(Class parameter)
           
 Object[] getComponents()
          Get all components (random order).
 Class[] getComponentTypes()
          Get all component types (random order).
 Object getMultipleInheritanceProxy()
          Shorthand for getAggregateComponentProxy(boolean, boolean)(true, true).
 boolean hasComponent(Class componentType)
          Does the container have a partilcilar component type?
protected  boolean hookEmUp(Class componentImplementation, Class componentType, boolean progress)
           
 void instantiateComponents()
          Initialize the container.
protected  Object makeComponentInstance(Class type, Constructor constructor, Object[] args)
           
 void registerComponent(Class componentImplementation)
           
 void registerComponent(Class componentType, Class componentImplementation)
           
 void registerComponent(Class componentType, Object component)
           
 void registerComponent(Object component)
           
protected  boolean reuseImplementationIfAppropriate(Class componentType, Class componentImplementation)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

orderedComponents

protected List orderedComponents

unmanagedComponents

protected List unmanagedComponents
Constructor Detail

DefaultPicoContainer

public DefaultPicoContainer(ComponentFactory componentFactory)
Method Detail

getComponents

public final Object[] getComponents()
Description copied from interface: PicoContainer
Get all components (random order).

Specified by:
getComponents in interface PicoContainer
Returns:
An array of components.

getMultipleInheritanceProxy

public Object getMultipleInheritanceProxy()
Shorthand for getAggregateComponentProxy(boolean, boolean)(true, true).

Returns:
a proxy.

getAggregateComponentProxy

public Object getAggregateComponentProxy(boolean callInInstantiationOrder,
                                         boolean callUnmanagedComponents)
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 container that implement that interface.

Parameters:
callInInstantiationOrder - whether to call the methods in the order of instantiation (true) or reverse (false)

registerComponent

public void registerComponent(Class componentType,
                              Class componentImplementation)
                       throws DuplicateComponentTypeRegistrationException,
                              AssignabilityRegistrationException,
                              NotConcreteRegistrationException,
                              WrongNumberOfConstructorsRegistrationException
Throws:
DuplicateComponentTypeRegistrationException
AssignabilityRegistrationException
NotConcreteRegistrationException
WrongNumberOfConstructorsRegistrationException

registerComponent

public void registerComponent(Object component)
                       throws PicoRegistrationException
Throws:
PicoRegistrationException

registerComponent

public void registerComponent(Class componentType,
                              Object component)
                       throws PicoRegistrationException
Throws:
PicoRegistrationException

addParameterToComponent

public void addParameterToComponent(Class componentType,
                                    Class parameter,
                                    Object arg)

registerComponent

public void registerComponent(Class componentImplementation)
                       throws DuplicateComponentTypeRegistrationException,
                              AssignabilityRegistrationException,
                              NotConcreteRegistrationException,
                              WrongNumberOfConstructorsRegistrationException
Throws:
DuplicateComponentTypeRegistrationException
AssignabilityRegistrationException
NotConcreteRegistrationException
WrongNumberOfConstructorsRegistrationException

instantiateComponents

public void instantiateComponents()
                           throws PicoInitializationException
Description copied from interface: PicoContainer
Initialize the container.

Specified by:
instantiateComponents in interface PicoContainer
Throws:
PicoInitializationException

hookEmUp

protected boolean hookEmUp(Class componentImplementation,
                           Class componentType,
                           boolean progress)
                    throws AmbiguousComponentResolutionException,
                           PicoInvocationTargetInitailizationException
Throws:
AmbiguousComponentResolutionException
PicoInvocationTargetInitailizationException

reuseImplementationIfAppropriate

protected boolean reuseImplementationIfAppropriate(Class componentType,
                                                   Class componentImplementation)

makeComponentInstance

protected Object makeComponentInstance(Class type,
                                       Constructor constructor,
                                       Object[] args)
                                throws PicoInvocationTargetInitailizationException
Throws:
PicoInvocationTargetInitailizationException

getComponentForParam

protected Object getComponentForParam(Class parameter)
                               throws AmbiguousComponentResolutionException
Throws:
AmbiguousComponentResolutionException

getComponent

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

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

getComponentTypes

public Class[] getComponentTypes()
Description copied from interface: PicoContainer
Get all component types (random order).

Specified by:
getComponentTypes in interface PicoContainer
Returns:
an array of component types.

hasComponent

public boolean hasComponent(Class componentType)
Description copied from interface: PicoContainer
Does the container have a partilcilar component type?

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


Copyright © Codehaus. All Rights Reserved.