CordaService
Keywords: net.corda.core.node.services.CordaService class
Date: 2023-09-18

net.corda.core.node.services

## Annotation Type CordaService

-     @Target
       @Retention
       @Target
      public CordaService

  Annotate any class that needs to be a long-lived service within the node, such as an oracle, with this annotation. Such a class needs to have a constructor with a single parameter of type AppServiceHub. This constructor will be invoked during node start to initialise the service. The service hub provided can be used to get information about the node that may be necessary for the service. Corda services are created as singletons within the node and are available to flows via `ServiceHub.cordaService`.

  The service class has to implement `interface SerializeAsToken` to ensure correct usage within flows. (If possible extend `class SingletonSerializeAsToken` instead as it removes the boilerplate.)

  See Also:
    AppServiceHub, `ServiceHub.cordaService`, `interface SerializeAsToken`, `class SingletonSerializeAsToken`