AppServiceHub
Keywords: net.corda.core.node.AppServiceHub interface
Date: 2023-09-18

net.corda.core.node

## Interface AppServiceHub

- All Superinterfaces:
    ServiceHub, ServicesForResolution

      public AppServiceHub
      extends ServiceHub

  A `annotationclass CordaService` annotated class requires a constructor taking a single parameter of type `interface AppServiceHub`. With the `interface AppServiceHub` parameter a `annotationclass CordaService` is able to access to privileged operations. In particular such a `annotationclass CordaService` can initiate and track flows marked with `annotationclass StartableByService`.

  See Also:
    `annotationclass CordaService`, `interface AppServiceHub`, `interface AppServiceHub`, `annotationclass CordaService`, `annotationclass CordaService`, `annotationclass StartableByService`

- - ### Field Detail

    - #### Companion

          static net.corda.core.node.AppServiceHub.Companion Companion

    - #### SERVICE_PRIORITY_HIGH

          static int SERVICE_PRIORITY_HIGH

      See Also:
        Constant Field Values

    - #### SERVICE_PRIORITY_NORMAL

          static int SERVICE_PRIORITY_NORMAL

      See Also:
        Constant Field Values

    - #### SERVICE_PRIORITY_LOW

          static int SERVICE_PRIORITY_LOW

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### AppServiceHub

          public AppServiceHub()

  - ### Method Detail

    - #### startFlow

          @NotNull
          <T> FlowHandle<T> startFlow(@NotNull
                                               FlowLogic<? extends T> flow)

      Start the given flow with the given arguments. `flow` must be annotated with `annotationclass StartableByService`. TODO it is assumed here that the flow object has an appropriate classloader.

      See Also:
        `flow`, `annotationclass StartableByService`

    - #### startTrackedFlow

          @NotNull
          <T> FlowProgressHandle<T> startTrackedFlow(@NotNull
                                                              FlowLogic<? extends T> flow)

      Start the given flow with the given arguments, returning an Observable with a single observation of the result of running the flow. `flow` must be annotated with `annotationclass StartableByService`. TODO it is assumed here that the flow object has an appropriate classloader.

      See Also:
        `flow`, `annotationclass StartableByService`

    - #### getDatabase

          @NotNull
          CordaTransactionSupport getDatabase()

      Accessor to `interface CordaTransactionSupport` in order to perform sensitive actions within new, independent top level transaction.

      There are times when a user thread may want to perform certain actions within a new top level DB transaction. This will be an independent transaction from those used in the framework.

      See Also:
        `interface CordaTransactionSupport`

    - #### register

          void register(int priority,
                        @NotNull
                        ServiceLifecycleObserver observer)

      Allows to register `interface ServiceLifecycleObserver` such that it will start receiving `enum ServiceLifecycleEvent`s

      Parameters:
        `priority` - controls to which queue `observer` will be added. Higher values correspond to higher priorities.
        `observer` - an instance of `interface ServiceLifecycleObserver` to be registered.
      See Also:
        `interface ServiceLifecycleObserver`, `enum ServiceLifecycleEvent`

    - #### register

          <T> void register(int priority,
                            @NotNull
                            kotlin.jvm.functions.Function1<? super net.corda.core.node.services.ServiceLifecycleEvent,? extends T> func)

      Convenience method to be able to add an arbitrary function as a `register` callback.

      See Also:
        `register`