corda / net.corda.core.node / AppServiceHub

AppServiceHub

interface AppServiceHub : ServiceHub

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

Properties

database

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

abstract val database: CordaTransactionSupport

Functions

register

Allows to register ServiceLifecycleObserver such that it will start receiving net.corda.core.node.services.ServiceLifecycleEvents

abstract fun register(priority: Int = SERVICE_PRIORITY_NORMAL, observer: ServiceLifecycleObserver): Unit

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

open fun <T> register(priority: Int = SERVICE_PRIORITY_NORMAL, func: (ServiceLifecycleEvent) -> T): Unit

startFlow

Start the given flow with the given arguments. flow must be annotated with net.corda.core.flows.StartableByService. TODO it is assumed here that the flow object has an appropriate classloader.

abstract fun <T> startFlow(flow: FlowLogic<T>): FlowHandle<T>

startTrackedFlow

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 net.corda.core.flows.StartableByService. TODO it is assumed here that the flow object has an appropriate classloader.

abstract fun <T> startTrackedFlow(flow: FlowLogic<T>): FlowProgressHandle<T>

Companion Object Properties

SERVICE_PRIORITY_HIGH

const val SERVICE_PRIORITY_HIGH: Int

SERVICE_PRIORITY_LOW

const val SERVICE_PRIORITY_LOW: Int

SERVICE_PRIORITY_NORMAL

const val SERVICE_PRIORITY_NORMAL: Int

Extension Functions

getCashBalance

fun ServiceHub.getCashBalance(currency: Currency): Amount<Currency>

getCashBalances

fun ServiceHub.getCashBalances(): Map<Currency, Amount<Currency>>

ledger

Creates and tests a ledger built by the passed in dsl.

fun ServiceHub.ledger(notary: Party = TestIdentity.fresh("ledger notary").party, script: LedgerDSL<TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.() -> Unit): LedgerDSL<TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>

transaction

Creates a ledger with a single transaction, built by the passed in dsl.

fun ServiceHub.transaction(notary: Party = TestIdentity.fresh("transaction notary").party, script: TransactionDSL<TransactionDSLInterpreter>.() -> EnforceVerifyOrFail): LedgerDSL<TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>