Class InstanceImpl<T>

java.lang.Object
org.jboss.weld.bean.builtin.AbstractFacade<T,jakarta.enterprise.inject.Instance<T>>
org.jboss.weld.bean.builtin.InstanceImpl<T>
Type Parameters:
T -
All Implemented Interfaces:
jakarta.enterprise.inject.Instance<T>, jakarta.inject.Provider<T>, Serializable, Iterable<T>, WeldInstance<T>

public class InstanceImpl<T> extends AbstractFacade<T,jakarta.enterprise.inject.Instance<T>> implements WeldInstance<T>, Serializable
Helper implementation for Instance for getting instances
Author:
Gavin King
See Also:
  • Method Details

    • of

      public static <I> jakarta.enterprise.inject.Instance<I> of(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint, jakarta.enterprise.context.spi.CreationalContext<I> creationalContext, BeanManagerImpl beanManager)
    • get

      public T get()
      Specified by:
      get in interface jakarta.inject.Provider<T>
    • toString

      public String toString()
      Gets a string representation
      Overrides:
      toString in class Object
      Returns:
      A string representation
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • isAmbiguous

      public boolean isAmbiguous()
      Specified by:
      isAmbiguous in interface jakarta.enterprise.inject.Instance<T>
    • isUnsatisfied

      public boolean isUnsatisfied()
      Specified by:
      isUnsatisfied in interface jakarta.enterprise.inject.Instance<T>
    • select

      public WeldInstance<T> select(Annotation... qualifiers)
      Specified by:
      select in interface jakarta.enterprise.inject.Instance<T>
      Specified by:
      select in interface WeldInstance<T>
    • select

      public <U extends T> WeldInstance<U> select(Class<U> subtype, Annotation... qualifiers)
      Specified by:
      select in interface jakarta.enterprise.inject.Instance<T>
      Specified by:
      select in interface WeldInstance<T>
    • select

      public <U extends T> WeldInstance<U> select(jakarta.enterprise.util.TypeLiteral<U> subtype, Annotation... qualifiers)
      Specified by:
      select in interface jakarta.enterprise.inject.Instance<T>
      Specified by:
      select in interface WeldInstance<T>
    • select

      public <X> WeldInstance<X> select(Type subtype, Annotation... qualifiers)
      Description copied from interface: WeldInstance

      Obtains a child Instance for the given required type and additional required qualifiers. Must be invoked on Instance<T> where T is Object.

      Specified by:
      select in interface WeldInstance<T>
      Type Parameters:
      X - the required type
      Parameters:
      subtype - a Type representing the required type
      qualifiers - the additional required qualifiers
      Returns:
      the child Instance
    • destroy

      public void destroy(T instance)
      Specified by:
      destroy in interface jakarta.enterprise.inject.Instance<T>
    • getHandle

      public jakarta.enterprise.inject.Instance.Handle<T> getHandle()
      Specified by:
      getHandle in interface jakarta.enterprise.inject.Instance<T>
    • getHandler

      public WeldInstance.Handler<T> getHandler()
      Description copied from interface: WeldInstance
      This method is deprecated as a similar functioning method exists in CDI 4.0 and newer. Users should instead use Instance.getHandle(). Obtains an initialized contextual reference handler for the bean that has the required type and required qualifiers and is eligible for injection.

      The contextual reference is obtained lazily, i.e. when first needed.

      Specified by:
      getHandler in interface WeldInstance<T>
      Returns:
      a new handler
    • isResolvable

      public boolean isResolvable()
      Specified by:
      isResolvable in interface jakarta.enterprise.inject.Instance<T>
    • handles

      public Iterable<jakarta.enterprise.inject.Instance.Handle<T>> handles()
      Specified by:
      handles in interface jakarta.enterprise.inject.Instance<T>
    • handlers

      public Iterable<WeldInstance.Handler<T>> handlers()
      Description copied from interface: WeldInstance
      This method is deprecated as a similar functioning method exists in CDI 4.0 and newer. Users should instead use Instance.handles(). Allows to iterate over contextual reference handlers for all the beans that have the required type and required qualifiers and are eligible for injection.

      Note that the returned Iterable is stateless and so each Iterable.iterator() produces a new set of handlers.

      Specified by:
      handlers in interface WeldInstance<T>
      Returns:
      a new iterable
    • getPriorityComparator

      public Comparator<WeldInstance.Handler<?>> getPriorityComparator()
      Description copied from interface: WeldInstance
      This method is deprecated in favor of WeldInstance.getHandlePriorityComparator() which operates on a non-deprecated Instance.Handle interface. The returned comparator sorts handlers by priority in descending order.
      • A class-based bean whose annotated type has jakarta.annotation.Priority has the priority of value jakarta.annotation.Priority#value()
      • A custom bean which implements Prioritized has the priority of value Prioritized.getPriority()
      • Any other bean has the priority of value 0
      Specified by:
      getPriorityComparator in interface WeldInstance<T>
      Returns:
      a comparator instance
    • getHandlePriorityComparator

      public Comparator<jakarta.enterprise.inject.Instance.Handle<?>> getHandlePriorityComparator()
      Description copied from interface: WeldInstance
      The returned comparator sorts handles by priority in descending order.
      • A class-based bean whose annotated type has jakarta.annotation.Priority has the priority of value jakarta.annotation.Priority#value()
      • A custom bean which implements Prioritized has the priority of value Prioritized.getPriority()
      • Any other bean has the priority of value 0
      Specified by:
      getHandlePriorityComparator in interface WeldInstance<T>
      Returns:
      a comparator instance