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>
BasicInjectionTargetimplementation. The implementation supports:- @Inject injection + initializers
- @PostConstruct/@PreDestroy callbacks
- Author:
- Pete Muir, Jozef Hartinger
-
-
Field Summary
Fields Modifier and Type Field Description protected BeanManagerImplbeanManager
-
Constructor Summary
Constructors Modifier Constructor Description protectedBasicInjectionTarget(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager, Injector<T> injector, LifecycleCallbackInvoker<T> invoker)protectedBasicInjectionTarget(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager, Injector<T> injector, LifecycleCallbackInvoker<T> invoker, Instantiator<T> instantiator)protectedBasicInjectionTarget(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 voidcheckType(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)CreatesInjectionTargetfor interceptors which do not have associatedInterceptor.voiddispose(T instance)Destroys the instance.AnnotatedType<T>getAnnotated()AnnotatedType<T>getAnnotatedType()Bean<T>getBean()Returns aBeanthis producer is associated with or null if no such bean exists.BeanManagerImplgetBeanManager()Set<InjectionPoint>getInjectionPoints()Returns the set of allInjectionPoints.Injector<T>getInjector()Instantiator<T>getInstantiator()LifecycleCallbackInvoker<T>getLifecycleCallbackInvoker()protected SlimAnnotatedType<T>getType()booleanhasDecorators()booleanhasInterceptors()protected voidinitializeAfterBeanDiscovery(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.voidinject(T instance, CreationalContext<T> ctx)Performs dependency injection upon the given object.voidpostConstruct(T instance)Calls thePostConstructcallback, if it exists, according to the semantics required by the Java EE platform specification.voidpreDestroy(T instance)Calls thePreDestroycallback, if it exists, according to the semantics required by the Jakarta EE platform specification.Tproduce(CreationalContext<T> ctx)Causes an instance to be produced via theProducer.voidsetInstantiator(Instantiator<T> instantiator)StringtoString()-
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)
CreatesInjectionTargetfor interceptors which do not have associatedInterceptor. These interceptors are a result of usingInterceptorsannotation directly on the target class.
-
checkType
protected void checkType(EnhancedAnnotatedType<T> type)
-
produce
public T produce(CreationalContext<T> ctx)
Description copied from interface:ProducerCauses an instance to be produced via the
Producer.If the
Producerrepresents a class, this will invoke the constructor annotatedInjectif 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
Producerrepresents 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:
producein interfaceProducer<T>- Parameters:
ctx- TheCreationalContextto use for the produced object- Returns:
- the instance produced
-
inject
public void inject(T instance, CreationalContext<T> ctx)
Description copied from interface:InjectionTargetPerforms dependency injection upon the given object. Performs Jakarta EE component environment injection, sets the value of all injected fields, and calls all initializer methods.
- Specified by:
injectin interfaceInjectionTarget<T>- Parameters:
instance- The instance upon which to perform injectionctx- TheCreationalContextto use for creating new instances
-
postConstruct
public void postConstruct(T instance)
Description copied from interface:InjectionTargetCalls the
PostConstructcallback, if it exists, according to the semantics required by the Java EE platform specification.- Specified by:
postConstructin interfaceInjectionTarget<T>- Parameters:
instance- The instance on which to invoke thePostConstructmethod
-
preDestroy
public void preDestroy(T instance)
Description copied from interface:InjectionTargetCalls the
PreDestroycallback, if it exists, according to the semantics required by the Jakarta EE platform specification.- Specified by:
preDestroyin interfaceInjectionTarget<T>- Parameters:
instance- The instance on which to invoke thePreDestroymethod
-
dispose
public void dispose(T instance)
Description copied from interface:ProducerDestroys the instance.
If the
Producerrepresents a class, then this operation does nothing.If the
Producerrepresents 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:ProducerReturns the set of all
InjectionPoints. If theProducerrepresents a class, then this returns returns the set ofInjectionPointobjects representing all injected fields, bean constructor parameters and initializer method parameters. For a producer method, this returns the set ofInjectionPointobjects representing all parameters of the producer method.- Specified by:
getInjectionPointsin 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:
getAnnotatedin classAbstractProducer<T>
-
getAnnotatedType
public AnnotatedType<T> getAnnotatedType()
- Specified by:
getAnnotatedTypein interfaceorg.jboss.weld.manager.api.WeldInjectionTarget<T>
-
getLifecycleCallbackInvoker
public LifecycleCallbackInvoker<T> getLifecycleCallbackInvoker()
-
getBean
public Bean<T> getBean()
Description copied from class:AbstractProducerReturns aBeanthis producer is associated with or null if no such bean exists.- Specified by:
getBeanin classAbstractProducer<T>
-
-