Class BeanConfiguratorBase<THIS extends BeanConfiguratorBase<THIS,T>,T>

java.lang.Object
io.quarkus.arc.processor.ConfiguratorBase<THIS>
io.quarkus.arc.processor.BeanConfiguratorBase<THIS,T>
All Implemented Interfaces:
Consumer<org.jboss.jandex.AnnotationInstance>
Direct Known Subclasses:
BeanConfigurator

public abstract class BeanConfiguratorBase<THIS extends BeanConfiguratorBase<THIS,T>,T> extends ConfiguratorBase<THIS> implements Consumer<org.jboss.jandex.AnnotationInstance>
This construct is not thread-safe.
  • Field Details

    • identifier

      protected String identifier
    • implClazz

      protected final org.jboss.jandex.DotName implClazz
    • types

      protected final Set<org.jboss.jandex.Type> types
    • registeredTypeClosures

      protected final Set<org.jboss.jandex.Type> registeredTypeClosures
    • typesToRemove

      protected final Set<org.jboss.jandex.Type> typesToRemove
    • qualifiers

      protected final Set<org.jboss.jandex.AnnotationInstance> qualifiers
    • scope

      protected ScopeInfo scope
    • alternative

      protected Boolean alternative
    • stereotypes

      protected final List<StereotypeInfo> stereotypes
    • name

      protected String name
    • creatorConsumer

      protected Consumer<io.quarkus.gizmo.MethodCreator> creatorConsumer
    • destroyerConsumer

      protected Consumer<io.quarkus.gizmo.MethodCreator> destroyerConsumer
    • defaultBean

      protected boolean defaultBean
    • removable

      protected boolean removable
    • providerType

      protected org.jboss.jandex.Type providerType
    • forceApplicationClass

      protected boolean forceApplicationClass
    • targetPackageName

      protected String targetPackageName
    • priority

      protected Integer priority
    • injectionPoints

      protected final Set<InjectionPointInfo.TypeAndQualifiers> injectionPoints
    • startupPriority

      protected Integer startupPriority
    • interceptionProxy

      protected io.quarkus.arc.processor.InterceptionProxyInfo interceptionProxy
    • checkActiveConsumer

      protected Consumer<io.quarkus.gizmo.MethodCreator> checkActiveConsumer
  • Constructor Details

    • BeanConfiguratorBase

      protected BeanConfiguratorBase(org.jboss.jandex.DotName implClazz)
  • Method Details

    • read

      public THIS read(BeanConfiguratorBase<?,?> base)
      Read metadata from another configurator base.
      Parameters:
      base -
      Returns:
      self
    • types

      public THIS types(Class<?>... types)
    • types

      public THIS types(org.jboss.jandex.Type... types)
    • addType

      public THIS addType(org.jboss.jandex.DotName className)
    • addType

      public THIS addType(org.jboss.jandex.Type type)
    • addType

      public THIS addType(Class<?> type)
    • addTypeClosure

      public THIS addTypeClosure(org.jboss.jandex.DotName typeName)
      Adds an unrestricted set of bean types for the given type as if it represented a bean class of a managed bean.
      Parameters:
      typeName - DotName representation of a class that should be scanned for types
      Returns:
      self
    • addTypeClosure

      public THIS addTypeClosure(Class<?> type)
      Adds an unrestricted set of bean types for the given type as if it represented a bean class of a managed bean.
      Parameters:
      type - a class that should be scanned for types
      Returns:
      self
    • addTypeClosure

      public THIS addTypeClosure(org.jboss.jandex.Type type)
      Adds an unrestricted set of bean types for the given type as if it represented a bean class of a managed bean.
      Parameters:
      type - Type representation of a class that should be scanned for types
      Returns:
      self
    • removeTypes

      public THIS removeTypes(Class<?>... types)
      Removes listed types from the resulting types of the synthetic bean.
      Parameters:
      types - types that should be removed from the resulting set of bean types
      Returns:
      self
    • removeTypes

      public THIS removeTypes(org.jboss.jandex.DotName... types)
      Removes listed types from the resulting types of the synthetic bean.
      Parameters:
      types - types that should be removed from the resulting set of bean types
      Returns:
      self
    • removeTypes

      public THIS removeTypes(org.jboss.jandex.Type... types)
      Removes listed types from the resulting types of the synthetic bean.
      Parameters:
      types - types that should be removed from the resulting set of bean types
      Returns:
      self
    • addQualifier

      public THIS addQualifier(Class<? extends Annotation> annotationClass)
    • addQualifier

      public THIS addQualifier(org.jboss.jandex.DotName annotationName)
    • addQualifier

      public THIS addQualifier(org.jboss.jandex.AnnotationInstance qualifier)
    • addQualifier

      public QualifierConfigurator<THIS> addQualifier()
    • qualifiers

      public THIS qualifiers(org.jboss.jandex.AnnotationInstance... qualifiers)
    • scope

      public THIS scope(ScopeInfo scope)
    • scope

      public THIS scope(Class<? extends Annotation> scope)
    • name

      public THIS name(String name)
    • named

      public THIS named(String name)
      Unlike the name(String) method, a new Named qualifier with the specified value is added to the configured bean.
      Parameters:
      name -
      Returns:
      self
    • defaultBean

      public THIS defaultBean()
    • unremovable

      public THIS unremovable()
    • forceApplicationClass

      public THIS forceApplicationClass()
      Forces the bean to be considered an 'application class', so it will be defined in the runtime ClassLoader and re-created on each redeployment.
      Returns:
      self
    • targetPackageName

      public THIS targetPackageName(String name)
    • alternative

      public THIS alternative(boolean alternative)
    • priority

      public THIS priority(int value)
    • addStereotype

      public THIS addStereotype(StereotypeInfo stereotype)
    • stereotypes

      public THIS stereotypes(StereotypeInfo... stereotypes)
    • providerType

      public THIS providerType(org.jboss.jandex.Type providerType)
      The provider type is the "real" type of the bean instance created via InjectableReferenceProvider.get(CreationalContext).

      The container attempts to derive the provider type from the implementation class. However, in some cases it's better to specify it manually.

      Parameters:
      providerType -
      Returns:
      self
    • addInjectionPoint

      public THIS addInjectionPoint(org.jboss.jandex.Type requiredType, org.jboss.jandex.AnnotationInstance... requiredQualifiers)
      Adds a synthetic injection point. The injection point is validated at build time and is also considered when removing unused beans.
      Parameters:
      requiredType -
      requiredQualifiers -
      Returns:
      self
      See Also:
    • startup

      public THIS startup(int priority)
      Initialize the bean eagerly at application startup.

      If this bean is not active (see checkActive(Consumer)) and is not injected into any always active bean, eager initialization is skipped to prevent needless failures.

      Parameters:
      priority - priority of the generated synthetic observer, to affect eager init ordering
      Returns:
      self
    • startup

      public THIS startup()
      Initialize the bean eagerly at application startup.

      If this bean is not active (see checkActive(Consumer)) and is not injected into any always active bean, eager initialization is skipped to prevent needless failures.

      Returns:
      self
    • injectInterceptionProxy

      public THIS injectInterceptionProxy()
      Declares that this synthetic bean has an injection point of type InterceptionProxy<PT>, where PT is the provider type of this bean. An instance of PT may be used as a parameter to InterceptionProxy.create(Object) in the creator of this synthetic bean.

      The class of the provider type is scanned for interceptor binding annotations.

      This method may only be called once. If called multiple times, the last call wins and the previous calls are lost.

      Returns:
      self
    • injectInterceptionProxy

      public THIS injectInterceptionProxy(Class<?> bindingsSource)
      Declares that this synthetic bean has an injection point of type InterceptionProxy<PT>, where PT is the provider type of this bean. An instance of PT may be used as a parameter to InterceptionProxy.create(Object) in the creator of this synthetic bean.

      If the bindingsSource is not null, interceptor bindings on the class of the provider type are ignored; instead, the bindingsSource class is scanned for interceptor binding annotations as defined in BindingsSource.

      This method may only be called once. If called multiple times, the last call wins and the previous calls are lost.

      Parameters:
      bindingsSource - the bindings source class, may be null
      Returns:
      self
    • injectInterceptionProxy

      public THIS injectInterceptionProxy(org.jboss.jandex.DotName bindingsSource)
      Declares that this synthetic bean has an injection point of type InterceptionProxy<PT>, where PT is the provider type of this bean. An instance of PT may be used as a parameter to InterceptionProxy.create(Object) in the creator of this synthetic bean.

      If the bindingsSource is not null, interceptor bindings on the class of the provider type are ignored; instead, the bindingsSource class is scanned for interceptor binding annotations as defined in BindingsSource.

      This method may only be called once. If called multiple times, the last call wins and the previous calls are lost.

      Parameters:
      bindingsSource - the bindings source class, may be null
      Returns:
      self
    • creator

      public <U extends T> THIS creator(Class<? extends BeanCreator<U>> creatorClazz)
    • creator

      public THIS creator(Consumer<io.quarkus.gizmo.MethodCreator> methodCreatorConsumer)
      The first method parameter is the synthetic creational context, i.e. the MethodCreator#getMethodParam(0) returns a SyntheticCreationalContext instance that can be used to obtain contextual references for synthetic injection points and build-time parameters.

      Furthermore, the consumer can also read the instance field of name params and type Map. This map holds all parameters set via one of the BeanConfigurator#param() methods.

      Parameters:
      methodCreatorConsumer -
      Returns:
      self
    • destroyer

      public <U extends T> THIS destroyer(Class<? extends BeanDestroyer<U>> destroyerClazz)
    • destroyer

      public THIS destroyer(Consumer<io.quarkus.gizmo.MethodCreator> methodCreatorConsumer)
    • checkActive

      public THIS checkActive(Class<? extends Supplier<ActiveResult>> checkActiveClazz)
      Configures the class of the "check active" procedure.
      See Also:
    • checkActive

      public THIS checkActive(Consumer<io.quarkus.gizmo.MethodCreator> methodCreatorConsumer)
      Configures the procedure that generates the bytecode for checking whether this bean is active or not. Usually, this method should not be called, because most beans are always active. However, certain synthetic beans may be inactive from time to time -- as determined by this procedure. If a bean is inactive, injecting it or looking it up ends with InactiveBeanException.

      The procedure is expected to return an ActiveResult, which for inactive beans must include an explanation (why is this bean not active) and optionally also a cause (in case the bean is inactive because another bean is also inactive).

      Returns:
      the procedure that generates the bytecode for checking whether this bean is active or not
    • identifier

      public THIS identifier(String identifier)
      The identifier becomes part of the BeanInfo.getIdentifier() and InjectableBean.getIdentifier().

      An identifier can be used to register multiple synthetic beans with the same set of types and qualifiers.

      Parameters:
      identifier -
      Returns:
      self
      See Also:
    • cast

      protected static <T> T cast(Object obj)
    • accept

      public void accept(org.jboss.jandex.AnnotationInstance qualifier)
      Specified by:
      accept in interface Consumer<THIS extends BeanConfiguratorBase<THIS,T>>