InvocationContext - corda

corda / net.corda.core.context / InvocationContext

# InvocationContext

`data class InvocationContext`

Models the information needed to trace an invocation in Corda. Includes initiating actor, origin, trace information, and optional external trace information to correlate clients' IDs.

### Constructors

#### <init> | `InvocationContext(origin: InvocationOrigin, trace: Trace, actor: Actor?, externalTrace: Trace? = null, impersonatedActor: Actor? = null)` `InvocationContext(origin: InvocationOrigin, trace: Trace, actor: Actor?, externalTrace: Trace? = null, impersonatedActor: Actor? = null, arguments: List<Any?>? = emptyList(), clientId: String? = null)` Models the information needed to trace an invocation in Corda. Includes initiating actor, origin, trace information, and optional external trace information to correlate clients' IDs. `InvocationContext(origin: InvocationOrigin, trace: Trace, actor: Actor?, externalTrace: Trace? = null, impersonatedActor: Actor? = null, arguments: List<Any?>? = emptyList(), clientId: String? = null, serializedTelemetry: SerializedTelemetry? = null)`

### Properties

#### actor | Acting agent of the invocation, used to derive the security principal. `val actor: Actor?`
#### arguments | `val arguments: List<Any?>?`
#### clientId | `val clientId: String?`
#### externalTrace | Optional external invocation trace for cross-system logs correlation. `val externalTrace: Trace?`
#### impersonatedActor | Optional impersonated actor, used for logging but not for authorisation. `val impersonatedActor: Actor?`
#### origin | Origin of the invocation. `val origin: InvocationOrigin`
#### serializedTelemetry | `val serializedTelemetry: SerializedTelemetry?`
#### trace | Corda invocation trace. `val trace: Trace`

### Functions

#### copy | `fun copy(origin: InvocationOrigin = this.origin, trace: Trace = this.trace, actor: Actor? = this.actor, externalTrace: Trace? = this.externalTrace, impersonatedActor: Actor? = this.impersonatedActor): InvocationContext` `fun copy(origin: InvocationOrigin = this.origin, trace: Trace = this.trace, actor: Actor? = this.actor, externalTrace: Trace? = this.externalTrace, impersonatedActor: Actor? = this.impersonatedActor, arguments: List<Any?>? = this.arguments, clientId: String? = this.clientId): InvocationContext`
#### principal | Associated security principal. `fun principal(): Principal`

### Companion Object Functions

#### newInstance | Creates an InvocationContext with a Trace that defaults to a java.util.UUID as value and java.time.Instant.now timestamp. `fun newInstance(origin: InvocationOrigin, trace: Trace = Trace.newInstance(), actor: Actor? = null, externalTrace: Trace? = null, impersonatedActor: Actor? = null, arguments: List<Any?> = emptyList(), clientId: String? = null, serializedTelemetry: SerializedTelemetry? = null): InvocationContext`
#### peer | Creates an InvocationContext with InvocationOrigin.Peer origin. `fun peer(party: CordaX500Name, trace: Trace = Trace.newInstance(), externalTrace: Trace? = null, impersonatedActor: Actor? = null): InvocationContext`
#### rpc | Creates an InvocationContext with InvocationOrigin.RPC origin. `fun rpc(actor: Actor, trace: Trace = Trace.newInstance(), externalTrace: Trace? = null, impersonatedActor: Actor? = null, arguments: List<Any?> = emptyList(), serializedTelemetry: SerializedTelemetry? = null): InvocationContext`
#### scheduled | Creates an InvocationContext with InvocationOrigin.Scheduled origin. `fun scheduled(scheduledState: ScheduledStateRef, trace: Trace = Trace.newInstance(), externalTrace: Trace? = null): InvocationContext`
#### service | Creates an InvocationContext with InvocationOrigin.Service origin. `fun service(serviceClassName: String, owningLegalIdentity: CordaX500Name, trace: Trace = Trace.newInstance(), externalTrace: Trace? = null): InvocationContext`
#### shell | Creates an InvocationContext with InvocationOrigin.Shell origin. `fun shell(trace: Trace = Trace.newInstance(), externalTrace: Trace? = null): InvocationContext`