picocontainer.defaults
Class DefaultPicoContainer

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

public class DefaultPicoContainer
extends Object
implements ClassRegistrationPicoContainer

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)
          Add a parameter to a component.
protected  Parameter createDefaultParameter()
           
 Object getAggregateComponentProxy()
          Shorthand for getAggregateComponentProxy(boolean, boolean)(true, true).
 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.
 Object[] getComponents()
          Get all components (random order).
 Class[] getComponentTypes()
          Get all component types (random order).
 boolean hasComponent(Class componentType)
          Does the container have a partilcilar component type?
 void instantiateComponents()
          Initialize the container.
 void registerComponent(Class componentImplementation)
          Registers a component.
 void registerComponent(Class componentType, Class componentImplementation)
          Alternate way of registering components with additional component type.
 void registerComponent(Class componentType, Class componentImplementation, Parameter[] parameters)
           
 void registerComponent(Class componentType, Object component)
          Registers a component that is instantiated and configured outside the container.
 void registerComponent(Object component)
          Registers an instantiated component.
 
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.

getAggregateComponentProxy

public Object getAggregateComponentProxy()
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,
                              PicoIntrospectionException
Description copied from interface: ClassRegistrationPicoContainer
Alternate way of registering components with additional component type.

Specified by:
registerComponent in interface ClassRegistrationPicoContainer
Parameters:
componentType - Component type
componentImplementation - The class of the component to instantiate
Throws:
DuplicateComponentTypeRegistrationException
AssignabilityRegistrationException
NotConcreteRegistrationException
PicoIntrospectionException

registerComponent

public void registerComponent(Class componentType,
                              Class componentImplementation,
                              Parameter[] parameters)
                       throws NotConcreteRegistrationException,
                              AssignabilityRegistrationException,
                              DuplicateComponentTypeRegistrationException
Specified by:
registerComponent in interface ClassRegistrationPicoContainer
Throws:
NotConcreteRegistrationException
AssignabilityRegistrationException
DuplicateComponentTypeRegistrationException

createDefaultParameter

protected Parameter createDefaultParameter()

registerComponent

public void registerComponent(Object component)
                       throws PicoRegistrationException
Description copied from interface: ClassRegistrationPicoContainer
Registers an instantiated component. This might be because you are creating trees of Pico containers or if you have a class that you want treated as a component, but is not Pico component compatible.

Specified by:
registerComponent in interface ClassRegistrationPicoContainer
Parameters:
component - The pre instantiated component to register
Throws:
PicoRegistrationException

registerComponent

public void registerComponent(Class componentType,
                              Object component)
                       throws PicoRegistrationException
Description copied from interface: ClassRegistrationPicoContainer
Registers a component that is instantiated and configured outside the container. Useful in cases where pico doesn't have sufficient knowledge to instantiate a component.

Specified by:
registerComponent in interface ClassRegistrationPicoContainer
Parameters:
componentType - Component type
component - preinstantiated component
Throws:
PicoRegistrationException - If a registration problem

addParameterToComponent

public void addParameterToComponent(Class componentType,
                                    Class parameter,
                                    Object arg)
                             throws PicoIntrospectionException
Description copied from interface: ClassRegistrationPicoContainer
Add a parameter to a component. Used for configuring them. Very liekly to change before release.

Specified by:
addParameterToComponent in interface ClassRegistrationPicoContainer
Parameters:
componentType - The component type
parameter - The parameter it pertains to
arg - The argukemt to pass in.
Throws:
PicoIntrospectionException

registerComponent

public void registerComponent(Class componentImplementation)
                       throws DuplicateComponentTypeRegistrationException,
                              AssignabilityRegistrationException,
                              NotConcreteRegistrationException,
                              PicoIntrospectionException
Description copied from interface: ClassRegistrationPicoContainer
Registers a component. Same as calling ClassRegistrationPicoContainer.registerComponent(java.lang.Class, java.lang.Class) with the same argument.

Specified by:
registerComponent in interface ClassRegistrationPicoContainer
Parameters:
componentImplementation - The class of the component to instantiate
Throws:
DuplicateComponentTypeRegistrationException
AssignabilityRegistrationException
NotConcreteRegistrationException
PicoIntrospectionException

instantiateComponents

public void instantiateComponents()
                           throws PicoInstantiationException,
                                  PicoInvocationTargetInitializationException,
                                  PicoIntrospectionException
Description copied from interface: PicoContainer
Initialize the container.

Specified by:
instantiateComponents in interface PicoContainer
Throws:
PicoInstantiationException
PicoInvocationTargetInitializationException
PicoIntrospectionException

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 final 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 © 2003 Codehaus. All Rights Reserved.