Class ManagedSagaFactory

java.lang.Object
org.j7m.middleware.application.distributed.ManagedSagaFactory
All Implemented Interfaces:
AutoCloseable, org.j7m.middleware.application.components.ManagedHostedResources.Factory, org.j7m.middleware.application.components.ManagedInvocationPolicy

public final class ManagedSagaFactory extends Object implements org.j7m.middleware.application.components.ManagedHostedResources.Factory, org.j7m.middleware.application.components.ManagedInvocationPolicy, AutoCloseable
General bounded POJO saga host and mandatory replay-phase policy. Native intents precede handlers; result encoding and completion run in owned finalization after actual USER work. No callback runs on timers or consensus threads. The same instance must be installed as factory and required policy.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    Safe host lifecycle observation; failureCategory contains only an exception class name.

    Nested classes/interfaces inherited from interface org.j7m.middleware.application.components.ManagedInvocationPolicy

    org.j7m.middleware.application.components.ManagedInvocationPolicy.Binding, org.j7m.middleware.application.components.ManagedInvocationPolicy.Phase, org.j7m.middleware.application.components.ManagedInvocationPolicy.Proceed
  • Constructor Summary

    Constructors
    Constructor
    Description
    ManagedSagaFactory(Map<String, ManagedSagaProfile> profiles, int concurrency, int pending)
    Creates finite host executors with middleware TCCL and no inherited application locals.
  • Method Summary

    Modifier and Type
    Method
    Description
    administrativeClient(String policy, String definition, int version)
    Explicitly grants a separate host-selected administrative client view.
    Set<Class<? extends Annotation>>
    Returns the supported managed saga annotation contract.
    org.j7m.middleware.application.components.ManagedHostedResources.Binding
    bind(org.j7m.middleware.application.api.ManagedHostedFeature feature, org.j7m.middleware.application.api.ManagedComponentDefinition<?> definition, Object component, org.j7m.middleware.application.components.ManagedHostedResources.Bundle bundle, org.j7m.middleware.application.components.ManagedHostedResources.Invoker invoker)
    Binds one activation without starting work before global admission commit.
    org.j7m.middleware.application.components.ManagedInvocationPolicy.Binding
    bind(org.j7m.middleware.application.api.ManagedServiceContract contract, Class<?> implementation, Class<?> businessInterface)
    Installs only trusted attempt context and owned result finalization; a raw Java call cannot acquire it.
    client(String policy, String definition, int version)
    Creates a resource-injectable facade for a host-selected definition and version.
    void
    Closes only after every activation has actually drained and released its binding.
    org.j7m.middleware.application.components.ManagedInvocationPolicy.Phase
    Places durable result recording outside participating transaction finalization.
    Set<org.j7m.middleware.application.components.ManagedInvocationPolicy>
    Requires the exact host policy instance, not a matching annotation token from another object.
    status(String definition, int version)
    Returns bounded lifecycle evidence without payloads or exception messages.
    void
    validate(org.j7m.middleware.application.api.ManagedHostedFeature feature, org.j7m.middleware.application.api.ManagedComponentDefinition<?> definition, org.j7m.middleware.application.components.ManagedHostedResources.Bundle bundle)
    Validates complete finite callback and schema metadata before constructors.
    void
    validate(org.j7m.middleware.application.api.ManagedServiceContract contract, Class<?> implementation, Class<?> businessInterface)
    Validates policy attachment to a generated saga callback, never an ordinary RPC alias.
    void
    validateComponent(Class<?> component, boolean exported)
    Rejects saga callback metadata without a concrete hosted definition.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.j7m.middleware.application.components.ManagedHostedResources.Factory

    backendKinds

    Methods inherited from interface org.j7m.middleware.application.components.ManagedInvocationPolicy

    bindHosted, validateExposure, validateHosted, validateHostedExposure, validateHostedExposure
  • Constructor Details

    • ManagedSagaFactory

      public ManagedSagaFactory(Map<String, ManagedSagaProfile> profiles, int concurrency, int pending)
      Creates finite host executors with middleware TCCL and no inherited application locals.
      Parameters:
      profiles - at most64 trusted named profiles
      concurrency - worker count, 1..8
      pending - bounded worker backlog, 1..64
      Throws:
      IllegalArgumentException - for invalid names or capacities
  • Method Details

    • annotationTypes

      public Set<Class<? extends Annotation>> annotationTypes()
      Returns the supported managed saga annotation contract.
      Specified by:
      annotationTypes in interface org.j7m.middleware.application.components.ManagedHostedResources.Factory
      Specified by:
      annotationTypes in interface org.j7m.middleware.application.components.ManagedInvocationPolicy
      Returns:
      exact immutable marker set
    • requiredPolicies

      public Set<org.j7m.middleware.application.components.ManagedInvocationPolicy> requiredPolicies()
      Requires the exact host policy instance, not a matching annotation token from another object.
      Specified by:
      requiredPolicies in interface org.j7m.middleware.application.components.ManagedHostedResources.Factory
      Returns:
      required policy identity
    • phase

      public org.j7m.middleware.application.components.ManagedInvocationPolicy.Phase phase()
      Places durable result recording outside participating transaction finalization.
      Specified by:
      phase in interface org.j7m.middleware.application.components.ManagedInvocationPolicy
      Returns:
      replay phase
    • validate

      public void validate(org.j7m.middleware.application.api.ManagedHostedFeature feature, org.j7m.middleware.application.api.ManagedComponentDefinition<?> definition, org.j7m.middleware.application.components.ManagedHostedResources.Bundle bundle)
      Validates complete finite callback and schema metadata before constructors.
      Specified by:
      validate in interface org.j7m.middleware.application.components.ManagedHostedResources.Factory
      Parameters:
      feature - generated feature
      definition - actual generated adapter
      bundle - verified program identity
      Throws:
      IllegalArgumentException - for unsupported shapes, profiles or forged descriptors
    • validateComponent

      public void validateComponent(Class<?> component, boolean exported)
      Rejects saga callback metadata without a concrete hosted definition.
      Specified by:
      validateComponent in interface org.j7m.middleware.application.components.ManagedInvocationPolicy
      Parameters:
      component - actual component class
      exported - whether it is a hosted/exported entry
      Throws:
      IllegalArgumentException - for unhosted saga metadata
    • validate

      public void validate(org.j7m.middleware.application.api.ManagedServiceContract contract, Class<?> implementation, Class<?> businessInterface)
      Validates policy attachment to a generated saga callback, never an ordinary RPC alias.
      Specified by:
      validate in interface org.j7m.middleware.application.components.ManagedInvocationPolicy
      Parameters:
      contract - actual hosted identity
      implementation - concrete POJO
      businessInterface - generated callback declaration type
      Throws:
      IllegalArgumentException - for missing profile or invalid exposure
    • bind

      public org.j7m.middleware.application.components.ManagedInvocationPolicy.Binding bind(org.j7m.middleware.application.api.ManagedServiceContract contract, Class<?> implementation, Class<?> businessInterface)
      Installs only trusted attempt context and owned result finalization; a raw Java call cannot acquire it.
      Specified by:
      bind in interface org.j7m.middleware.application.components.ManagedInvocationPolicy
      Parameters:
      contract - validated hosted callback
      implementation - actual POJO
      businessInterface - actual callback type
      Returns:
      per-export borrowed policy binding
    • bind

      public org.j7m.middleware.application.components.ManagedHostedResources.Binding bind(org.j7m.middleware.application.api.ManagedHostedFeature feature, org.j7m.middleware.application.api.ManagedComponentDefinition<?> definition, Object component, org.j7m.middleware.application.components.ManagedHostedResources.Bundle bundle, org.j7m.middleware.application.components.ManagedHostedResources.Invoker invoker)
      Binds one activation without starting work before global admission commit.
      Specified by:
      bind in interface org.j7m.middleware.application.components.ManagedHostedResources.Factory
      Parameters:
      feature - verified feature
      definition - actual adapter
      component - actual constructed POJO
      bundle - verified identity
      invoker - trusted fixed-authority owned callback handle
      Returns:
      owned lifecycle binding
      Throws:
      IllegalArgumentException - for invalid component or conflicting live definition
      IllegalStateException - for a closed/full factory
    • client

      public ManagedSagaClient client(String policy, String definition, int version)
      Creates a resource-injectable facade for a host-selected definition and version. The facade resolves only a currently admitted matching binding; it never chooses an endpoint from application input and cannot continue a different persisted artifact.
      Parameters:
      policy - exact host-selected backend profile
      definition - host-registered definition name
      version - positive definition version
      Returns:
      facade that remains unavailable until actual activation admission
      Throws:
      IllegalArgumentException - for invalid identity
    • administrativeClient

      public ManagedSagaClient administrativeClient(String policy, String definition, int version)
      Explicitly grants a separate host-selected administrative client view. The ordinary client never inherits the backend capability configured for internal reconciliation. Applications receive this view only through an explicit host registration; annotations and client metadata cannot turn an ordinary view into this capability.
      Parameters:
      policy - exact host-selected backend profile
      definition - trusted definition name
      version - positive definition version
      Returns:
      administrative view still requiring the profile's real server authorization
      Throws:
      IllegalArgumentException - for invalid identity
    • status

      public ManagedSagaFactory.Status status(String definition, int version)
      Returns bounded lifecycle evidence without payloads or exception messages.
      Parameters:
      definition - exact hosted definition
      version - definition version
      Returns:
      first matching local binding's actual status
      Throws:
      IllegalArgumentException - if no binding exists
    • close

      public void close()
      Closes only after every activation has actually drained and released its binding.
      Specified by:
      close in interface AutoCloseable
      Throws:
      IllegalStateException - while a binding still owns application work