Class 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>
    Basic InjectionTarget implementation. The implementation supports:
    • @Inject injection + initializers
    • @PostConstruct/@PreDestroy callbacks
    Interception and decoration is not supported but can be added using extension points.
    Author:
    Pete Muir, Jozef Hartinger
    • Method Detail

      • 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 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.

        Specified by:
        produce in interface Producer<T>
        Parameters:
        ctx - The CreationalContext 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 interface InjectionTarget<T>
        Parameters:
        instance - The instance upon which to perform injection
        ctx - The CreationalContext 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 interface InjectionTarget<T>
        Parameters:
        instance - The instance on which to invoke the PostConstruct 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 interface InjectionTarget<T>
        Parameters:
        instance - The instance on which to invoke the PreDestroy 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.

        Specified by:
        dispose in interface Producer<T>
        Parameters:
        instance - The instance to dispose
      • getInjectionPoints

        public Set<InjectionPoint> getInjectionPoints()
        Description copied from interface: 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.

        Specified by:
        getInjectionPoints in interface Producer<T>
        Returns:
        the set of all injection points for the producer
      • setInstantiator

        public void setInstantiator​(Instantiator<T> instantiator)
      • hasInterceptors

        public boolean hasInterceptors()
      • hasDecorators

        public boolean hasDecorators()
      • initializeAfterBeanDiscovery

        protected void initializeAfterBeanDiscovery​(EnhancedAnnotatedType<T> annotatedType)
      • getAnnotatedType

        public AnnotatedType<T> getAnnotatedType()
        Specified by:
        getAnnotatedType in interface org.jboss.weld.manager.api.WeldInjectionTarget<T>
      • getInjector

        public Injector<T> getInjector()