Class ManagedInvocationLifetime

java.lang.Object
org.j7m.middleware.application.components.ManagedInvocationLifetime
All Implemented Interfaces:
AutoCloseable, org.j7m.middleware.transport.api.InvocationCompletionScope

public final class ManagedInvocationLifetime extends Object implements org.j7m.middleware.transport.api.InvocationCompletionScope
Trusted host ownership for one invocation, independent of its caller's reply future. One serial actor shares CALL values across explicitly submitted work and codec continuations. Arbitrary cancelled application stages retain ownership because cancellation is not exit proof. No application-supplied future marker is consulted. Hidden work on arbitrary executors is outside the tracked-work contract; applications should use the supplied invocation control instead.
  • Constructor Details

    • ManagedInvocationLifetime

      public ManagedInvocationLifetime(ManagedContainer.CallScope callScope, org.j7m.middleware.application.api.InvocationContext context, org.j7m.middleware.security.api.SecurityContext security, Duration budget, Executor executor, int maximumTasks, int maximumPending, Runnable released)
      Creates a retained invocation; the executor must enforce host-wide finite admission.
      Parameters:
      callScope - newly opened call scope owned by this lifetime
      context - safe host-created invocation context; its control is replaced by this tracker
      security - actual authenticated security view, nullable for anonymous dispatch
      budget - original remaining monotonic budget, strictly positive and at most one day
      executor - borrowed bounded host executor, never closed by a lifetime
      maximumTasks - finite total child/continuation admissions for one invocation
      maximumPending - finite queued child/continuation admissions
      released - host callback after actual call disposal, invoked once even on disposal failure
  • Method Details

    • active

      public static boolean active()
      Reports whether the host installed a physical boundary on this thread. This observation exposes no mutable completion scope to application code.
      Returns:
      true inside host-owned root/worker/codec context
    • currentPhysicalCompletion

      public static CompletionStage<Void> currentPhysicalCompletion()
      Returns a read-only physical completion view for trusted host pipeline integration. Neither this view nor the application control exposes boundary exit or disposal authority.
      Returns:
      read-only completion, or null outside an owned context
    • requestCancellation

      public void requestCancellation()
      Specified by:
      requestCancellation in interface org.j7m.middleware.transport.api.InvocationCompletionScope
    • physicalCompletion

      public CompletionStage<Void> physicalCompletion()
      Specified by:
      physicalCompletion in interface org.j7m.middleware.transport.api.InvocationCompletionScope
    • logicalResult

      public CompletionStage<Object> logicalResult()
      Specified by:
      logicalResult in interface org.j7m.middleware.transport.api.InvocationCompletionScope
    • call

      public <T> T call(Callable<T> action) throws Exception
      Specified by:
      call in interface org.j7m.middleware.transport.api.InvocationCompletionScope
      Throws:
      Exception
    • supportsResultFinalizers

      public boolean supportsResultFinalizers()
      Specified by:
      supportsResultFinalizers in interface org.j7m.middleware.transport.api.InvocationCompletionScope
    • addResultFinalizer

      public void addResultFinalizer(org.j7m.middleware.transport.api.InvocationResultFinalizer finalizer)
      Specified by:
      addResultFinalizer in interface org.j7m.middleware.transport.api.InvocationCompletionScope
    • putContext

      public <T> void putContext(Class<T> type, T value)
      Specified by:
      putContext in interface org.j7m.middleware.transport.api.InvocationCompletionScope
    • context

      public <T> T context(Class<T> type)
      Specified by:
      context in interface org.j7m.middleware.transport.api.InvocationCompletionScope
    • findContext

      public <T> Optional<T> findContext(Class<T> type)
      Specified by:
      findContext in interface org.j7m.middleware.transport.api.InvocationCompletionScope
    • currentContext

      public static <T> T currentContext(Class<T> type)
      Reads an exact host-installed attachment inside the current serial CALL context. This read-only bridge supports existing named resource providers without exposing installation or completion authority to application code.
      Type Parameters:
      T - attachment type
      Parameters:
      type - exact trusted attachment key
      Returns:
      current invocation's attachment
      Throws:
      IllegalStateException - outside owned context or when the key is absent
      NullPointerException - for a null type
    • currentUserWorkOpen

      public static boolean currentUserWorkOpen()
      Reports whether the current owned context still admits application work and staged effects. Host finalizers and codecs may read attachments after settlement but cannot add USER work. This observation grants neither context installation nor physical-completion authority.
      Returns:
      false outside an owned context or after the atomic USER seal
    • markApplicationEntry

      public void markApplicationEntry()
      Specified by:
      markApplicationEntry in interface org.j7m.middleware.transport.api.InvocationCompletionScope
    • continueInContext

      public <T> CompletionStage<T> continueInContext(Callable<T> action)
      Specified by:
      continueInContext in interface org.j7m.middleware.transport.api.InvocationCompletionScope
    • abortBeforeTarget

      public void abortBeforeTarget()
      Specified by:
      abortBeforeTarget in interface org.j7m.middleware.transport.api.InvocationCompletionScope
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface org.j7m.middleware.transport.api.InvocationCompletionScope