Class BasicInjectionTarget<T>
- java.lang.Object
-
- org.jboss.weld.injection.producer.AbstractProducer<T>
-
- org.jboss.weld.injection.producer.BasicInjectionTarget<T>
-
- All Implemented Interfaces:
InjectionTarget<T>
,Producer<T>
,org.jboss.weld.manager.api.WeldInjectionTarget<T>
- Direct Known Subclasses:
BeanInjectionTarget
,NonProducibleInjectionTarget
public class BasicInjectionTarget<T> extends AbstractProducer<T> implements org.jboss.weld.manager.api.WeldInjectionTarget<T>
BasicInjectionTarget
implementation. The implementation supports:- @Inject injection + initializers
- @PostConstruct/@PreDestroy callbacks
- Author:
- Pete Muir, Jozef Hartinger
-
-
Field Summary
Fields Modifier and Type Field Description protected BeanManagerImpl
beanManager
-
Constructor Summary
Constructors Modifier Constructor Description protected
BasicInjectionTarget(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager, Injector<T> injector, LifecycleCallbackInvoker<T> invoker)
protected
BasicInjectionTarget(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager, Injector<T> injector, LifecycleCallbackInvoker<T> invoker, Instantiator<T> instantiator)
protected
BasicInjectionTarget(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager, Instantiator<T> instantiator)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkType(EnhancedAnnotatedType<T> type)
static <T> BasicInjectionTarget<T>
create(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager, Injector<T> injector, LifecycleCallbackInvoker<T> invoker)
static <T> BasicInjectionTarget<T>
createDefault(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager, Instantiator<T> instantiator)
static <T> BasicInjectionTarget<T>
createNonCdiInterceptor(EnhancedAnnotatedType<T> type, BeanManagerImpl beanManager)
CreatesInjectionTarget
for interceptors which do not have associatedInterceptor
.void
dispose(T instance)
Destroys the instance.AnnotatedType<T>
getAnnotated()
AnnotatedType<T>
getAnnotatedType()
Bean<T>
getBean()
Returns aBean
this producer is associated with or null if no such bean exists.BeanManagerImpl
getBeanManager()
Set<InjectionPoint>
getInjectionPoints()
Returns the set of allInjectionPoints
.Injector<T>
getInjector()
Instantiator<T>
getInstantiator()
LifecycleCallbackInvoker<T>
getLifecycleCallbackInvoker()
protected SlimAnnotatedType<T>
getType()
boolean
hasDecorators()
boolean
hasInterceptors()
protected void
initializeAfterBeanDiscovery(EnhancedAnnotatedType<T> annotatedType)
protected Instantiator<T>
initInstantiator(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager, Set<InjectionPoint> injectionPoints)
Returns an instantiator that will be used to create a new instance of a given component.void
inject(T instance, CreationalContext<T> ctx)
Performs dependency injection upon the given object.void
postConstruct(T instance)
Calls thePostConstruct
callback, if it exists, according to the semantics required by the Java EE platform specification.void
preDestroy(T instance)
Calls thePreDestroy
callback, if it exists, according to the semantics required by the Java EE platform specification.T
produce(CreationalContext<T> ctx)
Causes an instance to be produced via theProducer
.void
setInstantiator(Instantiator<T> instantiator)
String
toString()
-
Methods inherited from class org.jboss.weld.injection.producer.AbstractProducer
checkDelegateInjectionPoints, equals, hashCode
-
-
-
-
Field Detail
-
beanManager
protected final BeanManagerImpl beanManager
-
-
Constructor Detail
-
BasicInjectionTarget
protected BasicInjectionTarget(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager, Injector<T> injector, LifecycleCallbackInvoker<T> invoker)
-
BasicInjectionTarget
protected BasicInjectionTarget(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager, Injector<T> injector, LifecycleCallbackInvoker<T> invoker, Instantiator<T> instantiator)
-
BasicInjectionTarget
protected BasicInjectionTarget(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager, Instantiator<T> instantiator)
-
-
Method Detail
-
create
public static <T> BasicInjectionTarget<T> create(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager, Injector<T> injector, LifecycleCallbackInvoker<T> invoker)
-
createDefault
public static <T> BasicInjectionTarget<T> createDefault(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager, Instantiator<T> instantiator)
-
createNonCdiInterceptor
public static <T> BasicInjectionTarget<T> createNonCdiInterceptor(EnhancedAnnotatedType<T> type, BeanManagerImpl beanManager)
CreatesInjectionTarget
for interceptors which do not have associatedInterceptor
. These interceptors are a result of usingInterceptors
annotation directly on the target class.
-
checkType
protected void checkType(EnhancedAnnotatedType<T> type)
-
produce
public T produce(CreationalContext<T> ctx)
Description copied from interface:Producer
Causes an instance to be produced via the
Producer
.If the
Producer
represents a class, this will invoke the constructor annotatedInject
if it exists, or the constructor with no parameters otherwise. If the class has interceptors,produce()
is responsible for building the interceptors and decorators of the instance.If the
Producer
represents a producer field or method, this will invoke the producer method on, or access the producer field of, a contextual instance of the bean that declares the producer.- Specified by:
produce
in interfaceProducer<T>
- Parameters:
ctx
- TheCreationalContext
to use for the produced object- Returns:
- the instance produced
-
inject
public void inject(T instance, CreationalContext<T> ctx)
Description copied from interface:InjectionTarget
Performs dependency injection upon the given object. Performs Java EE component environment injection, sets the value of all injected fields, and calls all initializer methods.
- Specified by:
inject
in interfaceInjectionTarget<T>
- Parameters:
instance
- The instance upon which to perform injectionctx
- TheCreationalContext
to use for creating new instances
-
postConstruct
public void postConstruct(T instance)
Description copied from interface:InjectionTarget
Calls the
PostConstruct
callback, if it exists, according to the semantics required by the Java EE platform specification.- Specified by:
postConstruct
in interfaceInjectionTarget<T>
- Parameters:
instance
- The instance on which to invoke thePostConstruct
method
-
preDestroy
public void preDestroy(T instance)
Description copied from interface:InjectionTarget
Calls the
PreDestroy
callback, if it exists, according to the semantics required by the Java EE platform specification.- Specified by:
preDestroy
in interfaceInjectionTarget<T>
- Parameters:
instance
- The instance on which to invoke thePreDestroy
method
-
dispose
public void dispose(T instance)
Description copied from interface:Producer
Destroys the instance.
If the
Producer
represents a class, then this operation does nothing.If the
Producer
represents a producer field or method, this calls the disposer method, if any, on a contextual instance of the bean that declares the disposer method or performs any additional required cleanup, if any, to destroy state associated with a resource.
-
getInjectionPoints
public Set<InjectionPoint> getInjectionPoints()
Description copied from interface:Producer
Returns the set of all
InjectionPoints
. If theProducer
represents a class, then this returns returns the set ofInjectionPoint
objects representing all injected fields, bean constructor parameters and initializer method parameters. For a producer method, this returns the set ofInjectionPoint
objects representing all parameters of the producer method.- Specified by:
getInjectionPoints
in interfaceProducer<T>
- Returns:
- the set of all injection points for the producer
-
getType
protected SlimAnnotatedType<T> getType()
-
getBeanManager
public BeanManagerImpl getBeanManager()
-
getInstantiator
public Instantiator<T> getInstantiator()
-
setInstantiator
public void setInstantiator(Instantiator<T> instantiator)
-
hasInterceptors
public boolean hasInterceptors()
-
hasDecorators
public boolean hasDecorators()
-
initializeAfterBeanDiscovery
protected void initializeAfterBeanDiscovery(EnhancedAnnotatedType<T> annotatedType)
-
initInstantiator
protected Instantiator<T> initInstantiator(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager, Set<InjectionPoint> injectionPoints)
Returns an instantiator that will be used to create a new instance of a given component. If the instantiator uses a constructor with injection points, the implementation of theinitInstantiator(EnhancedAnnotatedType, Bean, BeanManagerImpl, Set)
method is supposed to register all these injection points within the injectionPoints set passed in as a parameter.
-
getAnnotated
public AnnotatedType<T> getAnnotated()
- Specified by:
getAnnotated
in classAbstractProducer<T>
-
getAnnotatedType
public AnnotatedType<T> getAnnotatedType()
- Specified by:
getAnnotatedType
in interfaceorg.jboss.weld.manager.api.WeldInjectionTarget<T>
-
getLifecycleCallbackInvoker
public LifecycleCallbackInvoker<T> getLifecycleCallbackInvoker()
-
getBean
public Bean<T> getBean()
Description copied from class:AbstractProducer
Returns aBean
this producer is associated with or null if no such bean exists.- Specified by:
getBean
in classAbstractProducer<T>
-
-