Record Class InvocationContext

java.lang.Object
java.lang.Record
org.j7m.middleware.application.api.InvocationContext
Record Components:
security - caller security context
application - application context
correlationId - correlation id
control - host-owned invocation controls; unavailable outside managed dispatch

public record InvocationContext(InvocationSecurityContext security, InvocationApplicationContext application, String correlationId, InvocationControl control) extends Record
Safe current invocation context exposed to application service code.

The record is immutable and thread-safe. It is installed by managed dispatch for the lifetime of one invocation and is cleared when dispatch completes. Cleanup is required for platform threads and virtual thread dispatch paths that use the internal scoped J7mContext. Application code must not retain the context as a long-lived authority token.

The context carries safe security, application, and correlation data. It does not expose credentials, raw transport internals, mutable runtime maps, or unredacted status data. Missing caller data is represented by an anonymous principal and empty correlation id rather than a null context. The control is a local host capability, not transport data: neither it nor this record is a wire DTO or a bearer token. Keeping this immutable record does not extend the control's invocation lifetime.

  • Constructor Details

    • InvocationContext

      public InvocationContext(InvocationSecurityContext security, InvocationApplicationContext application, String correlationId, InvocationControl control)
      Creates immutable context data.
    • InvocationContext

      public InvocationContext(InvocationSecurityContext security, InvocationApplicationContext application, String correlationId)
      Creates the compatible context without an active work-submission capability. Existing callers retain the original three-argument constructor; a managed host supplies the four-argument constructor when it installs its actual invocation lifetime.
      Parameters:
      security - caller security context, or null for anonymous data
      application - application context, or null for an empty context
      correlationId - correlation id, or null for an empty identifier
  • Method Details

    • empty

      public static InvocationContext empty()
      Creates an empty safe context for code running outside middleware dispatch.
      Returns:
      empty safe context
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • security

      public InvocationSecurityContext security()
      Returns the value of the security record component.
      Returns:
      the value of the security record component
    • application

      public InvocationApplicationContext application()
      Returns the value of the application record component.
      Returns:
      the value of the application record component
    • correlationId

      public String correlationId()
      Returns the value of the correlationId record component.
      Returns:
      the value of the correlationId record component
    • control

      public InvocationControl control()
      Returns the value of the control record component.
      Returns:
      the value of the control record component