public class BasicInjectionTarget<T> extends AbstractProducer<T> implements WeldInjectionTarget<T>
InjectionTarget
implementation. The implementation supports:
Modifier and Type | Field and Description |
---|---|
protected BeanManagerImpl |
beanManager |
Modifier | Constructor and 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) |
Modifier and Type | Method and 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) |
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)
Creates
InjectionTarget for interceptors which do not have associated Interceptor . |
void |
dispose(T instance)
Destroys the instance.
|
AnnotatedType<T> |
getAnnotated() |
AnnotatedType<T> |
getAnnotatedType() |
Bean<T> |
getBean()
Returns a
Bean this producer is associated with or null if no such bean exists. |
BeanManagerImpl |
getBeanManager() |
java.util.Set<InjectionPoint> |
getInjectionPoints()
Returns the set of all
InjectionPoints . |
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,
java.util.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 the
PostConstruct callback, if it exists, according to the semantics required by the Java
EE platform specification. |
void |
preDestroy(T instance)
Calls the
PreDestroy 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 the
Producer . |
void |
setInstantiator(Instantiator<T> instantiator) |
java.lang.String |
toString() |
checkDelegateInjectionPoints, equals, hashCode
protected final BeanManagerImpl beanManager
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)
public static <T> BasicInjectionTarget<T> create(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager, Injector<T> injector, LifecycleCallbackInvoker<T> invoker)
public static <T> BasicInjectionTarget<T> createDefault(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager)
public static <T> BasicInjectionTarget<T> createDefault(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager, Instantiator<T> instantiator)
public static <T> BasicInjectionTarget<T> createNonCdiInterceptor(EnhancedAnnotatedType<T> type, BeanManagerImpl beanManager)
InjectionTarget
for interceptors which do not have associated Interceptor
. These interceptors are a
result of using Interceptors
annotation directly on the target class.protected void checkType(EnhancedAnnotatedType<T> type)
public T produce(CreationalContext<T> ctx)
Producer
Causes an instance to be produced via the Producer
.
If the Producer
represents a class, this will invoke the constructor annotated Inject
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.
produce
in interface Producer<T>
ctx
- The CreationalContext
to use for the produced objectpublic void inject(T instance, CreationalContext<T> ctx)
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.
inject
in interface InjectionTarget<T>
instance
- The instance upon which to perform injectionctx
- The CreationalContext
to use for creating new instancespublic void postConstruct(T instance)
InjectionTarget
Calls the PostConstruct
callback, if it exists, according to the semantics required by the Java
EE platform specification.
postConstruct
in interface InjectionTarget<T>
instance
- The instance on which to invoke the PostConstruct
methodpublic void preDestroy(T instance)
InjectionTarget
Calls the PreDestroy
callback, if it exists, according to the semantics required by the Java EE
platform specification.
preDestroy
in interface InjectionTarget<T>
instance
- The instance on which to invoke the PreDestroy
methodpublic void dispose(T instance)
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.
public java.util.Set<InjectionPoint> getInjectionPoints()
Producer
Returns the set of all InjectionPoints
. If the Producer
represents a class, then this returns returns the
set of InjectionPoint
objects representing all injected fields, bean constructor parameters and initializer
method parameters. For a producer method, this returns the set of InjectionPoint
objects representing all
parameters of the producer method.
getInjectionPoints
in interface Producer<T>
protected SlimAnnotatedType<T> getType()
public BeanManagerImpl getBeanManager()
public Instantiator<T> getInstantiator()
public void setInstantiator(Instantiator<T> instantiator)
public boolean hasInterceptors()
public boolean hasDecorators()
protected void initializeAfterBeanDiscovery(EnhancedAnnotatedType<T> annotatedType)
protected Instantiator<T> initInstantiator(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager, java.util.Set<InjectionPoint> injectionPoints)
initInstantiator(EnhancedAnnotatedType, Bean, BeanManagerImpl, Set)
method is supposed to register all these
injection points within the injectionPoints set passed in as a parameter.public AnnotatedType<T> getAnnotated()
getAnnotated
in class AbstractProducer<T>
public AnnotatedType<T> getAnnotatedType()
getAnnotatedType
in interface WeldInjectionTarget<T>
public LifecycleCallbackInvoker<T> getLifecycleCallbackInvoker()
public java.lang.String toString()
toString
in class java.lang.Object
public Bean<T> getBean()
AbstractProducer
Bean
this producer is associated with or null if no such bean exists.getBean
in class AbstractProducer<T>
Copyright © 2014. All Rights Reserved.