public abstract class AbstractInjector<T> extends AbstractAdapter<T> implements Injector<T>
ComponentAdapter.getComponentInstance(PicoContainer, Type)
.
That means that when used with a PicoContainer, getComponent will
return a new object each time.Modifier and Type | Class and Description |
---|---|
static class |
AbstractInjector.AmbiguousComponentResolutionException
Exception that is thrown as part of the introspection.
|
static class |
AbstractInjector.CyclicDependencyException |
static class |
AbstractInjector.NotConcreteRegistrationException |
static class |
AbstractInjector.UnsatisfiableDependenciesException
Exception thrown when some of the component's dependencies are not satisfiable.
|
ComponentAdapter.NOTHING
Modifier and Type | Field and Description |
---|---|
protected Parameter[] |
parameters
The parameters to use for initialization.
|
protected org.picocontainer.injectors.AbstractInjector.ThreadLocalCyclicDependencyGuard |
verifyingGuard
The cycle guard for the verification.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractInjector(Object componentKey,
Class<?> componentImplementation,
Parameter[] parameters,
ComponentMonitor monitor,
boolean useNames)
Constructs a new ComponentAdapter for the given key and implementation.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(PicoVisitor visitor)
Accepts a visitor for this ComponentAdapter.
|
protected Type |
box(Type parameterType) |
protected T |
caughtIllegalAccessException(ComponentMonitor componentMonitor,
Constructor<T> constructor,
IllegalAccessException e,
PicoContainer container)
inform monitor about access exception.
|
protected Object |
caughtIllegalAccessException(ComponentMonitor componentMonitor,
Member member,
Object componentInstance,
IllegalAccessException e) |
protected T |
caughtInstantiationException(ComponentMonitor componentMonitor,
Constructor<T> constructor,
InstantiationException e,
PicoContainer container)
inform monitor about component instantiation failure
|
protected T |
caughtInvocationTargetException(ComponentMonitor componentMonitor,
Member member,
Object componentInstance,
InvocationTargetException e)
inform monitor about exception while instantiating component
|
protected Parameter[] |
createDefaultParameters(int length)
Create default parameters for the given types.
|
Object |
decorateComponentInstance(PicoContainer container,
Type into,
T instance)
A preexiting component instance can be injected into after instantiation
|
T |
getComponentInstance(PicoContainer container)
Retrieve the component instance.
|
abstract T |
getComponentInstance(PicoContainer container,
Type into)
Retrieve the component instance.
|
String |
getDescriptor()
Get a string key descriptor of the component adapter for use in toString()
|
protected T |
newInstance(Constructor<T> constructor,
Object[] parameters)
Instantiate an object with given parameters and respect the accessible flag.
|
boolean |
useNames() |
void |
verify(PicoContainer container)
Verify that all dependencies for this adapter can be satisfied.
|
changeMonitor, checkTypeCompatibility, currentMonitor, findAdapterOfType, getComponentImplementation, getComponentKey, getDelegate, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
findAdapterOfType, getComponentImplementation, getComponentKey, getDelegate
protected transient org.picocontainer.injectors.AbstractInjector.ThreadLocalCyclicDependencyGuard verifyingGuard
protected transient Parameter[] parameters
protected AbstractInjector(Object componentKey, Class<?> componentImplementation, Parameter[] parameters, ComponentMonitor monitor, boolean useNames)
componentKey
- the search key for this implementationcomponentImplementation
- the concrete implementationparameters
- the parameters to use for the initializationmonitor
- the component monitor used by this ComponentAdapterAbstractInjector.NotConcreteRegistrationException
- if the implementation is not a concrete classNullPointerException
- if one of the parameters is null
public boolean useNames()
protected Parameter[] createDefaultParameters(int length)
length
- parameter list lengthpublic void verify(PicoContainer container) throws PicoCompositionException
ComponentAdapter
verify
in interface ComponentAdapter<T>
container
- the PicoContainer
, that is used to resolve any possible dependencies of the instance.PicoCompositionException
- if one or more dependencies cannot be resolved.public T getComponentInstance(PicoContainer container) throws PicoCompositionException
ComponentAdapter
Cached
will always return the
same instance.getComponentInstance
in interface ComponentAdapter<T>
getComponentInstance
in class AbstractAdapter<T>
container
- the PicoContainer
, that is used to resolve any possible dependencies of the instance.PicoCompositionException
- if the component has dependencies which could not be resolved, or
instantiation of the component lead to an ambigous situation within the
container.public abstract T getComponentInstance(PicoContainer container, Type into) throws PicoCompositionException
ComponentAdapter
Cached
will always return the
same instance.getComponentInstance
in interface ComponentAdapter<T>
container
- the PicoContainer
, that is used to resolve any possible dependencies of the instance.into
- the class that is about to be injected into. Use ComponentAdapter.NOTHING.class if this is not important to you.PicoCompositionException
- if the component has dependencies which could not be resolved, or
instantiation of the component lead to an ambiguous situation within the
container.public Object decorateComponentInstance(PicoContainer container, Type into, T instance)
Injector
decorateComponentInstance
in interface Injector<T>
container
- the container that can provide injectable dependenciesinstance
- the instance topublic void accept(PicoVisitor visitor)
ComponentAdapter
PicoContainer
, that
cascades the visitor also down to all its ComponentAdapter instances.accept
in interface ComponentAdapter<T>
accept
in class AbstractAdapter<T>
visitor
- the visitor.public String getDescriptor()
ComponentAdapter
getDescriptor
in interface ComponentAdapter<T>
protected T newInstance(Constructor<T> constructor, Object[] parameters) throws InstantiationException, IllegalAccessException, InvocationTargetException
constructor
- the constructor to useparameters
- the parameters for the constructorInstantiationException
IllegalAccessException
InvocationTargetException
protected T caughtInstantiationException(ComponentMonitor componentMonitor, Constructor<T> constructor, InstantiationException e, PicoContainer container)
componentMonitor
- constructor
- e
- container
- protected T caughtIllegalAccessException(ComponentMonitor componentMonitor, Constructor<T> constructor, IllegalAccessException e, PicoContainer container)
componentMonitor
- constructor
- e
- container
- protected T caughtInvocationTargetException(ComponentMonitor componentMonitor, Member member, Object componentInstance, InvocationTargetException e)
componentMonitor
- member
- componentInstance
- e
- protected Object caughtIllegalAccessException(ComponentMonitor componentMonitor, Member member, Object componentInstance, IllegalAccessException e)
Copyright © 2003–2015 Codehaus. All rights reserved.