Package org.picocontainer.injectors
Class SetterInjector<T>
- java.lang.Object
-
- org.picocontainer.adapters.AbstractAdapter<T>
-
- org.picocontainer.injectors.AbstractInjector<T>
-
- org.picocontainer.injectors.IterativeInjector<T>
-
- org.picocontainer.injectors.SetterInjector<T>
-
- All Implemented Interfaces:
java.io.Serializable,ComponentAdapter<T>,ComponentMonitorStrategy,Injector<T>
- Direct Known Subclasses:
AnnotatedMethodInjector,NamedMethodInjector
public class SetterInjector<T> extends IterativeInjector<T>
Instantiates components using empty constructors and Setter Injection. For easy setting of primitive properties, also seePropertyApplicator. Note that this class doesn't cache instances. If you want caching, use aCachedaround this one.- Author:
- Aslak Hellesøy, Jörg Schaible, Mauro Talevi, Paul Hammant
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.picocontainer.injectors.AbstractInjector
AbstractInjector.AmbiguousComponentResolutionException, AbstractInjector.CyclicDependencyException, AbstractInjector.NotConcreteRegistrationException, AbstractInjector.UnsatisfiableDependenciesException
-
Nested classes/interfaces inherited from interface org.picocontainer.ComponentAdapter
ComponentAdapter.NOTHING
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Stringprefix-
Fields inherited from class org.picocontainer.injectors.IterativeInjector
bindings, injectionMembers, injectionTypes
-
Fields inherited from class org.picocontainer.injectors.AbstractInjector
parameters, verifyingGuard
-
-
Constructor Summary
Constructors Constructor Description SetterInjector(java.lang.Object componentKey, java.lang.Class componentImplementation, Parameter[] parameters, ComponentMonitor monitor, java.lang.String prefix, java.lang.String notThisOneThough, boolean optional, boolean useNames)Constructs a SetterInjector
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetDescriptor()Get a string key descriptor of the component adapter for use in toString()protected java.lang.StringgetInjectorPrefix()protected java.lang.ObjectinjectIntoMember(java.lang.reflect.AccessibleObject member, java.lang.Object componentInstance, java.lang.Object toInject)protected booleanisInjectorMethod(java.lang.reflect.Method method)protected java.lang.ObjectmemberInvocationReturn(java.lang.Object lastReturn, java.lang.reflect.AccessibleObject member, java.lang.Object instance)protected voidunsatisfiedDependencies(PicoContainer container, java.util.Set<java.lang.reflect.Type> unsatisfiableDependencyTypes, java.util.List<java.lang.reflect.AccessibleObject> unsatisfiableDependencyMembers)-
Methods inherited from class org.picocontainer.injectors.IterativeInjector
crudeMethodSignature, decorateComponentInstance, getComponentInstance, getConstructor, getName, initializeInjectionMembersAndTypeLists, makeParameterNameImpl, verify
-
Methods inherited from class org.picocontainer.injectors.AbstractInjector
accept, box, caughtIllegalAccessException, caughtIllegalAccessException, caughtInstantiationException, caughtInvocationTargetException, createDefaultParameters, getComponentInstance, newInstance, useNames
-
Methods inherited from class org.picocontainer.adapters.AbstractAdapter
changeMonitor, checkTypeCompatibility, currentMonitor, findAdapterOfType, getComponentImplementation, getComponentKey, getDelegate, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.picocontainer.ComponentAdapter
findAdapterOfType, getComponentImplementation, getComponentKey, getDelegate
-
-
-
-
Constructor Detail
-
SetterInjector
public SetterInjector(java.lang.Object componentKey, java.lang.Class componentImplementation, Parameter[] parameters, ComponentMonitor monitor, java.lang.String prefix, java.lang.String notThisOneThough, boolean optional, boolean useNames) throws AbstractInjector.NotConcreteRegistrationExceptionConstructs a SetterInjector- Parameters:
componentKey- the search key for this implementationcomponentImplementation- the concrete implementationparameters- the parameters to use for the initializationmonitor- the component monitor used by this addAdapterprefix- the prefix to use (e.g. 'set')notThisOneThough- a setter name that's not for injecting throughoptional- not all setters need to be injecteduseNames-- Throws:
AbstractInjector.NotConcreteRegistrationException- if the implementation is not a concrete class.java.lang.NullPointerException- if one of the parameters isnull
-
-
Method Detail
-
memberInvocationReturn
protected java.lang.Object memberInvocationReturn(java.lang.Object lastReturn, java.lang.reflect.AccessibleObject member, java.lang.Object instance)- Specified by:
memberInvocationReturnin classIterativeInjector<T>
-
injectIntoMember
protected java.lang.Object injectIntoMember(java.lang.reflect.AccessibleObject member, java.lang.Object componentInstance, java.lang.Object toInject) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException- Specified by:
injectIntoMemberin classIterativeInjector<T>- Throws:
java.lang.IllegalAccessExceptionjava.lang.reflect.InvocationTargetException
-
isInjectorMethod
protected boolean isInjectorMethod(java.lang.reflect.Method method)
- Overrides:
isInjectorMethodin classIterativeInjector<T>
-
getInjectorPrefix
protected java.lang.String getInjectorPrefix()
-
getDescriptor
public java.lang.String getDescriptor()
Description copied from interface:ComponentAdapterGet a string key descriptor of the component adapter for use in toString()- Specified by:
getDescriptorin interfaceComponentAdapter<T>- Overrides:
getDescriptorin classAbstractInjector<T>- Returns:
- the descriptor
-
unsatisfiedDependencies
protected void unsatisfiedDependencies(PicoContainer container, java.util.Set<java.lang.reflect.Type> unsatisfiableDependencyTypes, java.util.List<java.lang.reflect.AccessibleObject> unsatisfiableDependencyMembers)
- Specified by:
unsatisfiedDependenciesin classIterativeInjector<T>
-
-