Module jakarta.cdi

Interface BeanInfo

  • All Known Subinterfaces:
    InterceptorInfo

    public interface BeanInfo
    Beans are:
    • managed beans
    • beans defined by producer methods
    • beans defined by producer fields
    • synthetic beans
    Managed beans are also known as class-based beans, while beans defined by producer methods and producer fields are together also known as producer-based beans.

    Class-based and producer-based beans directly correspond to a declaration in program source code. Synthetic beans don't and are instead defined through other mechanisms, such as extensions.

    Since:
    4.0
    • Method Detail

      • scope

        ScopeInfo scope()
        Returns the scope of this bean.
        Returns:
        the scope of this bean, never null
      • types

        java.util.Collection<Type> types()
        Returns a collection of all types of this bean.
        Returns:
        immutable collection of bean types, never null
      • qualifiers

        java.util.Collection<AnnotationInfo> qualifiers()
        Returns a collection of this bean's qualifiers, represented as AnnotationInfo.
        Returns:
        immutable collection of qualifiers, never null
      • declaringClass

        ClassInfo declaringClass()
        Returns the class that declares this bean. In case of a managed bean, also known as class-based bean, that is the bean class directly. In case of a producer method or field, that is the class that declares the producer method or field. Returns null if this bean is synthetic.
        Returns:
        ClassInfo for the class that declares this bean, or null if this bean is synthetic
      • isClassBean

        boolean isClassBean()
        Returns whether this bean is a managed bean, also known as class-based bean.
        Returns:
        whether this bean is a managed bean
      • isProducerMethod

        boolean isProducerMethod()
        Returns whether this bean is defined by a producer method.
        Returns:
        whether this bean is defined by a producer method
      • isProducerField

        boolean isProducerField()
        Returns whether this bean is defined by a producer field.
        Returns:
        whether this bean is defined by a producer field
      • isSynthetic

        boolean isSynthetic()
        Returns whether this bean is synthetic. In other words, whether this bean does not correspond to a declaration in program source code and was created through other means (e.g. using an extension).
        Returns:
        whether this bean is synthetic
      • producerMethod

        MethodInfo producerMethod()
        Returns the producer method that defines this bean. Returns null if this bean is not defined by a producer method.
        Returns:
        producer method that defines this bean, or null if this bean is not defined by a producer method
      • producerField

        FieldInfo producerField()
        Returns the producer field that defines this bean. Returns null if this bean is not defined by a producer field.
        Returns:
        producer field that defines this bean, or null if this bean is not defined by a producer field
      • isAlternative

        boolean isAlternative()
        Returns whether this bean is an alternative.
        Returns:
        whether this bean is an alternative
      • priority

        java.lang.Integer priority()
        Returns the priority declared on this bean, or null if this bean does not declare a priority. Declaring a priority on an alternative bean makes it an enabled alternative. Similarly, declaring a priority on an interceptor makes it an enabled interceptor.
        Returns:
        the priority of this bean, or null if this bean does not declare a priority
      • name

        java.lang.String name()
        Returns the bean name of this bean. A bean name is usually defined using the @Named annotation. Returns null if the bean does not have a name.
        Returns:
        the bean name, or null if the bean does not have a name
      • disposer

        DisposerInfo disposer()
        Returns the disposer method of this producer-based bean. Returns null if this bean is not a defined by a producer method or a producer field, or if this producer-based bean does not have a corresponding disposer method.
        Returns:
        the disposer, or null if this bean does not have a disposer
      • stereotypes

        java.util.Collection<StereotypeInfo> stereotypes()
        Returns a collection of this bean's stereotypes.
        Returns:
        immutable collection of stereotypes, never null
      • injectionPoints

        java.util.Collection<InjectionPointInfo> injectionPoints()
        Returns a collection of this bean's injection points.
        Returns:
        immutable collection of injection points, never null
      • createInvoker

        InvokerBuilder<InvokerInfo> createInvoker​(MethodInfo method)
        Returns a new InvokerBuilder for given method. The builder eventually produces an opaque representation of the invoker for the given method.

        The method must be declared on the bean class or inherited from a supertype of the bean class of this bean, otherwise an exception is thrown.

        If an invoker may not be obtained for given method as described in Invoker, an exception is thrown.

        If this method is called outside the @Registration phase, an exception is thrown.

        Parameters:
        method - method of this bean, must not be null
        Returns:
        the invoker builder, never null
        Since:
        4.1
      • isInterceptor

        default boolean isInterceptor()
        Returns whether this bean is an interceptor.
        Returns:
        whether this bean is an interceptor
      • asInterceptor

        default InterceptorInfo asInterceptor()
        Returns this bean as an interceptor.
        Returns:
        this interceptor, never null
        Throws:
        java.lang.IllegalStateException - if isInterceptor() returns false