Annotation CordaInject

  • All Implemented Interfaces:
    java.lang.annotation.Annotation

    @Retention(value = RUNTIME)@Target(value = FIELD)@Documented() 
    public @interface CordaInject
    
                        

    The CordaInject annotation should be used within Flows to inject Corda's platform services.

    The annotation is placed onto a Flow's fields/properties and not on constructor parameters.

    Example usage:

    • Kotlin:
      
      class MyFlow : ClientStartableFlow {
      
          
          lateinit var flowEngine: FlowEngine
      
          
          lateinit var flowMessaging: FlowMessaging
      
          
          override fun call(requestBody: RestRequestBody): String {
              ...
          }
      }
      
    • Java:
      
      class MyFlow implements ClientStartableFlow {
      
          
          public FlowEngine flowEngine;
      
          
          public FlowMessaging flowMessaging;
      
          
          
          public String call(RestRequestBody requestBody) {
              ...
          }
      }
      
    The properties annotated with CordaInject can be public or private as the reflection that sets them can bypass their visibility modifiers. Making a Flow's properties public, internal or package private is convenient for unit testing and does not affect the Flow's runtime behaviour.

    The injected properties cannot be accessed within a Flow's constructor and should only be used from within a Flow's call method or subsequently executed code.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      • Methods inherited from class java.lang.annotation.Annotation

        annotationType, equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail