org.picocontainer.defaults
Class InstantiatingComponentAdapter

java.lang.Object
  extended byorg.picocontainer.defaults.AbstractComponentAdapter
      extended byorg.picocontainer.defaults.InstantiatingComponentAdapter
All Implemented Interfaces:
ComponentAdapter, Serializable
Direct Known Subclasses:
ConstructorInjectionComponentAdapter, SetterInjectionComponentAdapter

public abstract class InstantiatingComponentAdapter
extends AbstractComponentAdapter

This ComponentAdapter will instantiate a new object for each call to ComponentAdapter.getComponentInstance(). That means that when used with a PicoContainer, getComponentInstance will return a new object each time.

Version:
$Revision: 1.20 $
Author:
Aslak Hellesøy, Paul Hammant
See Also:
Serialized Form

Field Summary
protected  Parameter[] parameters
           
 
Constructor Summary
protected InstantiatingComponentAdapter(Object componentKey, Class componentImplementation, Parameter[] parameters, boolean allowNonPublicClasses)
           
 
Method Summary
protected  Parameter[] createDefaultParameters(Class[] parameters)
           
 Object getComponentInstance()
          Retrieve the component instance.
protected abstract  Constructor getGreediestSatisifableConstructor(List adapterInstantiationOrderTrackingList)
           
protected abstract  Object instantiateComponent(List adapterInstantiationOrderTrackingList)
          Instantiate the object.
protected  Object newInstance(Constructor constructor, Object[] parameters)
           
 void verify()
          Verify that all dependencies for this adapter can be satisifed.
 
Methods inherited from class org.picocontainer.defaults.AbstractComponentAdapter
getComponentImplementation, getComponentKey, getContainer, setContainer, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parameters

protected Parameter[] parameters
Constructor Detail

InstantiatingComponentAdapter

protected InstantiatingComponentAdapter(Object componentKey,
                                        Class componentImplementation,
                                        Parameter[] parameters,
                                        boolean allowNonPublicClasses)
Method Detail

getComponentInstance

public Object getComponentInstance()
                            throws PicoInitializationException,
                                   PicoIntrospectionException,
                                   AssignabilityRegistrationException,
                                   NotConcreteRegistrationException
Description copied from interface: ComponentAdapter
Retrieve the component instance. This method will usually create a new instance each time it is called, but that is not required. For example, CachingComponentAdapter will always return the same instance.

Returns:
the component instance.
Throws:
PicoInitializationException - if the component could not be instantiated.
PicoIntrospectionException - if the component has dependencies which could not be resolved, or instantiation of the component lead to an ambigous situation within the container.
AssignabilityRegistrationException
NotConcreteRegistrationException

createDefaultParameters

protected Parameter[] createDefaultParameters(Class[] parameters)

verify

public void verify()
            throws UnsatisfiableDependenciesException
Description copied from interface: ComponentAdapter
Verify that all dependencies for this adapter can be satisifed. Normally, the adapter should verify this by checking that the associated PicoContainer contains all the needed dependnecies.

Throws:
UnsatisfiableDependenciesException

newInstance

protected Object newInstance(Constructor constructor,
                             Object[] parameters)
                      throws InstantiationException,
                             IllegalAccessException,
                             InvocationTargetException
Throws:
InstantiationException
IllegalAccessException
InvocationTargetException

instantiateComponent

protected abstract Object instantiateComponent(List adapterInstantiationOrderTrackingList)
                                        throws PicoInitializationException,
                                               PicoIntrospectionException,
                                               AssignabilityRegistrationException,
                                               NotConcreteRegistrationException
Instantiate the object.

Parameters:
adapterInstantiationOrderTrackingList - This list is filled with the dependent adapters of the instance.
Returns:
Returns the new instance.
Throws:
PicoInitializationException
PicoIntrospectionException
AssignabilityRegistrationException
NotConcreteRegistrationException

getGreediestSatisifableConstructor

protected abstract Constructor getGreediestSatisifableConstructor(List adapterInstantiationOrderTrackingList)
                                                           throws PicoIntrospectionException,
                                                                  UnsatisfiableDependenciesException,
                                                                  AmbiguousComponentResolutionException,
                                                                  AssignabilityRegistrationException,
                                                                  NotConcreteRegistrationException
Throws:
PicoIntrospectionException
UnsatisfiableDependenciesException
AmbiguousComponentResolutionException
AssignabilityRegistrationException
NotConcreteRegistrationException


Copyright © 2003-2004 Codehaus. All Rights Reserved.