org.picocontainer.defaults
Class SetterInjectionComponentAdapter

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

public class SetterInjectionComponentAdapter
extends InstantiatingComponentAdapter

Instantiates components using empty constructors and Setter Injection. For easy setting of primitive properties, also see BeanPropertyComponentAdapter.

Note that this class doesn't cache instances. If you want caching, use a CachingComponentAdapter around this one.

Version:
$Revision: 1.14 $
Author:
Aslak Hellesøy, Jörg Schaible
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.picocontainer.defaults.InstantiatingComponentAdapter
InstantiatingComponentAdapter.Guard
 
Field Summary
 
Fields inherited from class org.picocontainer.defaults.InstantiatingComponentAdapter
allowNonPublicClasses, parameters, verifyingGuard
 
Constructor Summary
SetterInjectionComponentAdapter(Object componentKey, Class componentImplementation, Parameter[] parameters)
           
SetterInjectionComponentAdapter(Object componentKey, Class componentImplementation, Parameter[] parameters, boolean allowNonPublicClasses)
          {@inheritDoc} Explicitly specifies parameters, if null uses default parameters.
 
Method Summary
 Object getComponentInstance(PicoContainer container)
          Retrieve the component instance.
protected  Constructor getGreediestSatisfiableConstructor(PicoContainer container)
          Find and return the greediest satisfiable constructor.
 void verify(PicoContainer container)
          Verify that all dependencies for this adapter can be satisifed.
 
Methods inherited from class org.picocontainer.defaults.InstantiatingComponentAdapter
accept, createDefaultParameters, newInstance
 
Methods inherited from class org.picocontainer.defaults.AbstractComponentAdapter
checkTypeCompatibility, getComponentImplementation, getComponentKey, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SetterInjectionComponentAdapter

public SetterInjectionComponentAdapter(Object componentKey,
                                       Class componentImplementation,
                                       Parameter[] parameters,
                                       boolean allowNonPublicClasses)
                                throws AssignabilityRegistrationException,
                                       NotConcreteRegistrationException
{@inheritDoc} Explicitly specifies parameters, if null uses default parameters.


SetterInjectionComponentAdapter

public SetterInjectionComponentAdapter(Object componentKey,
                                       Class componentImplementation,
                                       Parameter[] parameters)
                                throws AssignabilityRegistrationException,
                                       NotConcreteRegistrationException
Method Detail

getGreediestSatisfiableConstructor

protected Constructor getGreediestSatisfiableConstructor(PicoContainer container)
                                                  throws PicoIntrospectionException,
                                                         UnsatisfiableDependenciesException,
                                                         AmbiguousComponentResolutionException,
                                                         AssignabilityRegistrationException,
                                                         NotConcreteRegistrationException
Description copied from class: InstantiatingComponentAdapter
Find and return the greediest satisfiable constructor.

Specified by:
getGreediestSatisfiableConstructor in class InstantiatingComponentAdapter
Parameters:
container - the PicoContainer to resolve dependencies.
Returns:
the found constructor.
Throws:
AmbiguousComponentResolutionException
UnsatisfiableDependenciesException
NotConcreteRegistrationException
PicoIntrospectionException
AssignabilityRegistrationException

getComponentInstance

public Object getComponentInstance(PicoContainer container)
                            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.

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

verify

public void verify(PicoContainer container)
            throws PicoIntrospectionException
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.

Specified by:
verify in interface ComponentAdapter
Overrides:
verify in class InstantiatingComponentAdapter
Throws:
PicoIntrospectionException


Copyright © 2003-2004 Codehaus. All Rights Reserved.