Class CDIDependencyInjectionAnnotator

java.lang.Object
org.drools.codegen.common.di.impl.CDIDependencyInjectionAnnotator
All Implemented Interfaces:
DependencyInjectionAnnotator

public class CDIDependencyInjectionAnnotator extends Object implements DependencyInjectionAnnotator
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns type that allows to mark instance as application component e.g.
    emitterType(String dataType)
    Returns type to be used as message emitter
    com.github.javaparser.ast.expr.Expression
    Creates an expression that returns a list of instances for given multi instance field
     
    Returns type that allows to inject multiple instances of the same type
    com.github.javaparser.ast.expr.Expression
    Creates an expression that represents optional instance for given field
    Returns type that allows to inject optional instances of the same type
    <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>>
    T
    Annotates given node with application level annotations e.g.
    <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>>
    T
    withConfigInjection(T node, String configKey)
    Annotates given node with configuration parameter injection
    <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>>
    T
    withConfigInjection(T node, String configKey, String defaultValue)
    Annotates given node with configuration parameter injection with default value
    <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>>
    T
    Annotates given node with a initializing annotation e.g.
    <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>>
    T
    Annotates given node with factory class annotations e.g.
    <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>>
    T
    Annotates given node with factory method annotations e.g.
    <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>>
    T
    withIncomingMessage(T node, String channel)
    Annotates given node with incoming message that it should consume from
    <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>>
    T
    withInjection(T node, boolean lazy)
    Annotates given node with injection annotations e.g.
    com.github.javaparser.ast.expr.MethodCallExpr
    withMessageProducer(com.github.javaparser.ast.expr.MethodCallExpr produceMethod, String channel, com.github.javaparser.ast.expr.Expression event)
    Annotates and enhances method used to produce messages
    <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>>
    T
    withNamed(T node, String name)
    Annotates given node with name annotation e.g.
    <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>>
    T
    Annotates given node with application level annotations e.g.
    <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>>
    T
    withNamedInjection(T node, String name)
    Annotates given node with injection annotations e.g.
    <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>>
    T
    Annotates given node with singleton level annotations e.g.
    <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>>
    T
    Annotates given node with optional injection annotations e.g.
    <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>>
    T
    withOutgoingMessage(T node, String channel)
    Annotates given node with outgoing message that it should send to
    <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>>
    T
    withProduces(T node, boolean isDefault)
    Annotates the given node with an annotation to produce a DI instance of the node target class, e.g.
    <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>>
    T
    Annotates given node with singleton level annotations e.g.
    <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>>
    T
    withTagAnnotation(T node, com.github.javaparser.ast.NodeList<com.github.javaparser.ast.expr.MemberValuePair> attributes)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.drools.codegen.common.di.DependencyInjectionAnnotator

    getOptionalInstance, withInjection, withSecurityRoles, withTransactional
  • Constructor Details

    • CDIDependencyInjectionAnnotator

      public CDIDependencyInjectionAnnotator()
  • Method Details

    • withProduces

      public <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>> T withProduces(T node, boolean isDefault)
      Description copied from interface: DependencyInjectionAnnotator
      Annotates the given node with an annotation to produce a DI instance of the node target class, e.g. Produces, Bean. This is used by configuration classes in the DI, like a factory method.
      Specified by:
      withProduces in interface DependencyInjectionAnnotator
      isDefault - indicates if the bean instance is created only if there are not any other bean of this type already declared in the application, e.g DefaultBean
    • withNamed

      public <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>> T withNamed(T node, String name)
      Description copied from interface: DependencyInjectionAnnotator
      Annotates given node with name annotation e.g. Named, Qualifier
      Specified by:
      withNamed in interface DependencyInjectionAnnotator
      Parameters:
      node - node to be annotated
    • withApplicationComponent

      public <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>> T withApplicationComponent(T node)
      Description copied from interface: DependencyInjectionAnnotator
      Annotates given node with application level annotations e.g. ApplicationScoped, Component
      Specified by:
      withApplicationComponent in interface DependencyInjectionAnnotator
      Parameters:
      node - node to be annotated
    • withNamedApplicationComponent

      public <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>> T withNamedApplicationComponent(T node, String name)
      Description copied from interface: DependencyInjectionAnnotator
      Annotates given node with application level annotations e.g. ApplicationScoped, Component additionally adding name to it
      Specified by:
      withNamedApplicationComponent in interface DependencyInjectionAnnotator
      Parameters:
      node - node to be annotated
      name - name to be assigned to given node
    • withSingletonComponent

      public <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>> T withSingletonComponent(T node)
      Description copied from interface: DependencyInjectionAnnotator
      Annotates given node with singleton level annotations e.g. Singleton, Component
      Specified by:
      withSingletonComponent in interface DependencyInjectionAnnotator
      Parameters:
      node - node to be annotated
    • withNamedSingletonComponent

      public <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>> T withNamedSingletonComponent(T node, String name)
      Description copied from interface: DependencyInjectionAnnotator
      Annotates given node with singleton level annotations e.g. Singleton, Component additionally adding name to it
      Specified by:
      withNamedSingletonComponent in interface DependencyInjectionAnnotator
      Parameters:
      node - node to be annotated
      name - name to be assigned to given node
    • withInjection

      public <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>> T withInjection(T node, boolean lazy)
      Description copied from interface: DependencyInjectionAnnotator
      Annotates given node with injection annotations e.g. Inject, Autowire
      Specified by:
      withInjection in interface DependencyInjectionAnnotator
      Parameters:
      node - node to be annotated
    • withNamedInjection

      public <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>> T withNamedInjection(T node, String name)
      Description copied from interface: DependencyInjectionAnnotator
      Annotates given node with injection annotations e.g. Inject, Autowire additionally adding name to it
      Specified by:
      withNamedInjection in interface DependencyInjectionAnnotator
      Parameters:
      node - node to be annotated
      name - name to be assigned to given node
    • withOptionalInjection

      public <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>> T withOptionalInjection(T node)
      Description copied from interface: DependencyInjectionAnnotator
      Annotates given node with optional injection annotations e.g. Inject, Autowire
      Specified by:
      withOptionalInjection in interface DependencyInjectionAnnotator
      Parameters:
      node - node to be annotated
    • withIncomingMessage

      public <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>> T withIncomingMessage(T node, String channel)
      Description copied from interface: DependencyInjectionAnnotator
      Annotates given node with incoming message that it should consume from
      Specified by:
      withIncomingMessage in interface DependencyInjectionAnnotator
      Parameters:
      node - node to be annotated
      channel - name of the channel messages should be consumer from
    • withOutgoingMessage

      public <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>> T withOutgoingMessage(T node, String channel)
      Description copied from interface: DependencyInjectionAnnotator
      Annotates given node with outgoing message that it should send to
      Specified by:
      withOutgoingMessage in interface DependencyInjectionAnnotator
      Parameters:
      node - node to be annotated
      channel - name of the channel messages should be send to
    • withMessageProducer

      public com.github.javaparser.ast.expr.MethodCallExpr withMessageProducer(com.github.javaparser.ast.expr.MethodCallExpr produceMethod, String channel, com.github.javaparser.ast.expr.Expression event)
      Description copied from interface: DependencyInjectionAnnotator
      Annotates and enhances method used to produce messages
      Specified by:
      withMessageProducer in interface DependencyInjectionAnnotator
      Parameters:
      produceMethod - method to be annotated
      channel - channel on which messages should be produced
      event - actual data to be send
    • optionalInstanceInjectionType

      public String optionalInstanceInjectionType()
      Description copied from interface: DependencyInjectionAnnotator
      Returns type that allows to inject optional instances of the same type
      Specified by:
      optionalInstanceInjectionType in interface DependencyInjectionAnnotator
      Returns:
      fully qualified class name
    • optionalInstanceExists

      public com.github.javaparser.ast.expr.Expression optionalInstanceExists(String fieldName)
      Description copied from interface: DependencyInjectionAnnotator
      Creates an expression that represents optional instance for given field
      Specified by:
      optionalInstanceExists in interface DependencyInjectionAnnotator
      Parameters:
      fieldName - name of the field that should be considered optional
      Returns:
      complete expression for optional instance
    • multiInstanceInjectionType

      public String multiInstanceInjectionType()
      Description copied from interface: DependencyInjectionAnnotator
      Returns type that allows to inject multiple instances of the same type
      Specified by:
      multiInstanceInjectionType in interface DependencyInjectionAnnotator
      Returns:
      fully qualified class name
    • getMultiInstance

      public com.github.javaparser.ast.expr.Expression getMultiInstance(String fieldName)
      Description copied from interface: DependencyInjectionAnnotator
      Creates an expression that returns a list of instances for given multi instance field
      Specified by:
      getMultiInstance in interface DependencyInjectionAnnotator
      Parameters:
      fieldName - name of the multi field that should be accessed
      Returns:
      complete expression for multi instance
    • applicationComponentType

      public String applicationComponentType()
      Description copied from interface: DependencyInjectionAnnotator
      Returns type that allows to mark instance as application component e.g. ApplicationScoped, Component
      Specified by:
      applicationComponentType in interface DependencyInjectionAnnotator
      Returns:
      fully qualified class name
    • emitterType

      public String emitterType(String dataType)
      Description copied from interface: DependencyInjectionAnnotator
      Returns type to be used as message emitter
      Specified by:
      emitterType in interface DependencyInjectionAnnotator
      Parameters:
      dataType - type of the data produces by the emitter
      Returns:
      fully qualified class name
    • withConfigInjection

      public <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>> T withConfigInjection(T node, String configKey)
      Description copied from interface: DependencyInjectionAnnotator
      Annotates given node with configuration parameter injection
      Specified by:
      withConfigInjection in interface DependencyInjectionAnnotator
      Parameters:
      node - node to be annotated
      configKey - name of the configuration property to be injected
    • withConfigInjection

      public <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>> T withConfigInjection(T node, String configKey, String defaultValue)
      Description copied from interface: DependencyInjectionAnnotator
      Annotates given node with configuration parameter injection with default value
      Specified by:
      withConfigInjection in interface DependencyInjectionAnnotator
      Parameters:
      node - node to be annotated
      configKey - name of the configuration property to be injected
      defaultValue - value to be used in case there is no config parameter defined
    • withEagerStartup

      public <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>> T withEagerStartup(T node)
      Description copied from interface: DependencyInjectionAnnotator
      Annotates given node with a initializing annotation e.g. Startup
      Specified by:
      withEagerStartup in interface DependencyInjectionAnnotator
      Parameters:
      node - node to be annotated
    • withFactoryClass

      public <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>> T withFactoryClass(T node)
      Description copied from interface: DependencyInjectionAnnotator
      Annotates given node with factory class annotations e.g. Configuration for Spring Boot
      Specified by:
      withFactoryClass in interface DependencyInjectionAnnotator
      Parameters:
      node - node to be annotated
    • withFactoryMethod

      public <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>> T withFactoryMethod(T node)
      Description copied from interface: DependencyInjectionAnnotator
      Annotates given node with factory method annotations e.g. Produces, Bean
      Specified by:
      withFactoryMethod in interface DependencyInjectionAnnotator
      Parameters:
      node - node to be annotated
    • getTransactionalAnnotation

      public String getTransactionalAnnotation()
      Specified by:
      getTransactionalAnnotation in interface DependencyInjectionAnnotator
    • withTagAnnotation

      public <T extends com.github.javaparser.ast.nodeTypes.NodeWithAnnotations<?>> T withTagAnnotation(T node, com.github.javaparser.ast.NodeList<com.github.javaparser.ast.expr.MemberValuePair> attributes)
      Specified by:
      withTagAnnotation in interface DependencyInjectionAnnotator