org.picocontainer.injectors
Class ConstructorInjector
java.lang.Object
org.picocontainer.adapters.AbstractAdapter
org.picocontainer.injectors.AbstractInjector
org.picocontainer.injectors.SingleMemberInjector
org.picocontainer.injectors.ConstructorInjector
- All Implemented Interfaces:
- Serializable, ComponentAdapter, ComponentMonitorStrategy, LifecycleStrategy
public class ConstructorInjector
- extends SingleMemberInjector
Instantiates components using Constructor Injection.
Note that this class doesn't cache instances. If you want caching,
use a Cached around this one.
- Author:
- Paul Hammant, Aslak Hellesøy, Jon Tirsén, Zohar Melamed, Jörg Schaible, Mauro Talevi
- See Also:
- Serialized Form
| Methods inherited from class org.picocontainer.injectors.AbstractInjector |
accept, caughtIllegalAccessException, caughtIllegalAccessException, caughtInstantiationException, caughtInvocationTargetException, createDefaultParameters, dispose, hasLifecycle, newInstance, start, stop |
ConstructorInjector
public ConstructorInjector(Object componentKey,
Class componentImplementation,
Parameter[] parameters,
ComponentMonitor monitor,
LifecycleStrategy lifecycleStrategy)
throws AbstractInjector.NotConcreteRegistrationException
- Creates a ConstructorInjector
- Parameters:
componentKey - the search key for this implementationcomponentImplementation - the concrete implementationparameters - the parameters to use for the initializationmonitor - the component monitor used by this addAdapterlifecycleStrategy - the component lifecycle strategy used by this addAdapter
- Throws:
AbstractInjector.NotConcreteRegistrationException - if the implementation is not a concrete class.
NullPointerException - if one of the parameters is null
getGreediestSatisfiableConstructor
protected Constructor getGreediestSatisfiableConstructor(PicoContainer container)
throws PicoCompositionException
- Throws:
PicoCompositionException
getComponentInstance
public Object getComponentInstance(PicoContainer container)
throws PicoCompositionException
- 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,
Cached 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:
PicoCompositionException - if the component could not be instantiated.
getMemberArguments
protected Object[] getMemberArguments(PicoContainer container,
Constructor ctor)
verify
public void verify(PicoContainer container)
throws PicoCompositionException
- 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- Specified by:
verify in class AbstractInjector
- Parameters:
container - the PicoContainer, that is used to resolve any possible dependencies of the instance.
- Throws:
PicoCompositionException - if one or more dependencies cannot be resolved.
toString
public String toString()
- Overrides:
toString in class AbstractAdapter
- Returns:
- Returns the ComponentAdapter's class name and the component's key.
- See Also:
Object.toString()
Copyright © 2003-2007 Codehaus. All Rights Reserved.