CordaService - corda

corda / net.corda.core.node.services / CordaService

# CordaService

`@Target([AnnotationTarget.CLASS]) annotation class 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 SerializeAsToken to ensure correct usage within flows. (If possible extend SingletonSerializeAsToken instead as it removes the boilerplate.)

### Constructors

#### <init> | 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. `CordaService()`