Class DefaultMiddlewareRuntime

java.lang.Object
org.j7m.middleware.core.DefaultMiddlewareRuntime
All Implemented Interfaces:
AutoCloseable, org.j7m.middleware.api.MiddlewareRuntime, org.j7m.middleware.transport.api.RuntimeTransportContext

public final class DefaultMiddlewareRuntime extends Object implements org.j7m.middleware.api.MiddlewareRuntime, org.j7m.middleware.transport.api.RuntimeTransportContext
Default Phase 1 middleware runtime implementation.

The runtime is thread-safe. It owns its registry client, transport providers, heartbeat scheduler, exported object descriptors, and invocation log. Public failures are normalized into MiddlewareException.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates and starts a runtime from configuration.
    DefaultMiddlewareRuntime(RuntimeConfiguration configuration, List<? extends AutoCloseable> ownedResources)
    Creates and starts a runtime from configuration and additional lifecycle-owned resources.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    org.j7m.middleware.codec.api.ValueCodec
    List<org.j7m.middleware.api.ObjectRegistration<?>>
    commitPreparedExports(List<? extends org.j7m.middleware.api.PreparedObjectRegistration<?>> preparedExports)
    decodeValue(org.j7m.middleware.codec.api.EncodedValue value, Class<?> expectedType)
    describeTarget(org.j7m.middleware.api.ObjectRef target)
    org.j7m.middleware.codec.api.EncodedValue
    dispatch(org.j7m.middleware.api.ObjectRef target, org.j7m.middleware.transport.api.MethodDescriptor method, List<org.j7m.middleware.codec.api.EncodedValue> arguments, org.j7m.middleware.api.InvocationOptions options)
    org.j7m.middleware.codec.api.EncodedValue
    dispatchLogicalAsyncTrusted(org.j7m.middleware.api.ObjectRef target, org.j7m.middleware.transport.api.MethodDescriptor method, List<org.j7m.middleware.codec.api.EncodedValue> arguments, org.j7m.middleware.api.InvocationOptions options, org.j7m.middleware.security.api.SecurityContext trustedContext, org.j7m.middleware.transport.api.InvocationCancellation cancellation)
    org.j7m.middleware.codec.api.EncodedValue
    dispatchTrusted(org.j7m.middleware.api.ObjectRef target, org.j7m.middleware.transport.api.MethodDescriptor method, List<org.j7m.middleware.codec.api.EncodedValue> arguments, org.j7m.middleware.api.InvocationOptions options, org.j7m.middleware.security.api.SecurityContext trustedContext)
    org.j7m.middleware.codec.api.EncodedValue
    encodeValue(Object value, Class<?> declaredType)
    void
    <T> org.j7m.middleware.api.ObjectRegistration<T>
    export(String serviceName, T instance, Class<T> primaryInterface, org.j7m.middleware.api.ExportOptions options)
    org.j7m.middleware.api.ObjectRef
    exportCallback(Object value, Class<?> declaredType)
    org.j7m.middleware.api.RuntimeIdentity
    List<org.j7m.middleware.api.ObjectRef>
    list(String serviceName, List<String> interfaces, Map<String,String> requiredParams, org.j7m.middleware.api.LookupOptions options)
    <T> T
    lookup(String serviceName, Class<T> api, org.j7m.middleware.api.LookupOptions options)
    <T> org.j7m.middleware.api.PreparedObjectRegistration<T>
    prepareExport(String serviceName, T instance, Class<T> primaryInterface, org.j7m.middleware.api.ExportOptions options)
    <T> T
    proxyFor(org.j7m.middleware.api.ObjectRef ref, Class<T> api)
    <T> T
    reference(org.j7m.middleware.api.ObjectRef reference, Class<T> contract, org.j7m.middleware.api.ProxyOptions options)
    void
    releaseInvocationCallbacks(List<org.j7m.middleware.codec.api.EncodedValue> encodedArguments)
    org.j7m.middleware.api.RuntimeStatus
    void
    validateTarget(org.j7m.middleware.api.ObjectRef target, String requiredInterface)

    Methods inherited from class Object

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

    Methods inherited from interface org.j7m.middleware.transport.api.RuntimeTransportContext

    releaseFailedInvocationCallbacks
  • Constructor Details

    • DefaultMiddlewareRuntime

      public DefaultMiddlewareRuntime(RuntimeConfiguration configuration)
      Creates and starts a runtime from configuration.
      Parameters:
      configuration - runtime configuration
    • DefaultMiddlewareRuntime

      public DefaultMiddlewareRuntime(RuntimeConfiguration configuration, List<? extends AutoCloseable> ownedResources)
      Creates and starts a runtime from configuration and additional lifecycle-owned resources.

      The supplied resources are closed during runtime shutdown before exported objects, executors, transports, and the registry are closed. The kernel treats these resources only as generic AutoCloseable instances; callers must not rely on kernel knowledge of higher-level resource semantics.

      Parameters:
      configuration - runtime configuration
      ownedResources - additional resources owned by the runtime
  • Method Details

    • identity

      public org.j7m.middleware.api.RuntimeIdentity identity()
      Specified by:
      identity in interface org.j7m.middleware.api.MiddlewareRuntime
      Specified by:
      identity in interface org.j7m.middleware.transport.api.RuntimeTransportContext
    • codec

      public org.j7m.middleware.codec.api.ValueCodec codec()
      Specified by:
      codec in interface org.j7m.middleware.transport.api.RuntimeTransportContext
    • export

      public <T> org.j7m.middleware.api.ObjectRegistration<T> export(String serviceName, T instance, Class<T> primaryInterface, org.j7m.middleware.api.ExportOptions options)
      Specified by:
      export in interface org.j7m.middleware.api.MiddlewareRuntime
    • prepareExport

      public <T> org.j7m.middleware.api.PreparedObjectRegistration<T> prepareExport(String serviceName, T instance, Class<T> primaryInterface, org.j7m.middleware.api.ExportOptions options)
      Specified by:
      prepareExport in interface org.j7m.middleware.api.MiddlewareRuntime
    • commitPreparedExports

      public List<org.j7m.middleware.api.ObjectRegistration<?>> commitPreparedExports(List<? extends org.j7m.middleware.api.PreparedObjectRegistration<?>> preparedExports)
      Specified by:
      commitPreparedExports in interface org.j7m.middleware.api.MiddlewareRuntime
    • lookup

      public <T> T lookup(String serviceName, Class<T> api, org.j7m.middleware.api.LookupOptions options)
      Specified by:
      lookup in interface org.j7m.middleware.api.MiddlewareRuntime
    • list

      public List<org.j7m.middleware.api.ObjectRef> list(String serviceName, List<String> interfaces, Map<String,String> requiredParams, org.j7m.middleware.api.LookupOptions options)
      Specified by:
      list in interface org.j7m.middleware.api.MiddlewareRuntime
    • status

      public org.j7m.middleware.api.RuntimeStatus status()
      Specified by:
      status in interface org.j7m.middleware.api.MiddlewareRuntime
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface org.j7m.middleware.api.MiddlewareRuntime
    • encodeValue

      public org.j7m.middleware.codec.api.EncodedValue encodeValue(Object value, Class<?> declaredType)
      Specified by:
      encodeValue in interface org.j7m.middleware.transport.api.RuntimeTransportContext
    • decodeValue

      public Object decodeValue(org.j7m.middleware.codec.api.EncodedValue value, Class<?> expectedType)
      Specified by:
      decodeValue in interface org.j7m.middleware.transport.api.RuntimeTransportContext
    • dispatch

      public org.j7m.middleware.codec.api.EncodedValue dispatch(org.j7m.middleware.api.ObjectRef target, org.j7m.middleware.transport.api.MethodDescriptor method, List<org.j7m.middleware.codec.api.EncodedValue> arguments, org.j7m.middleware.api.InvocationOptions options)
      Specified by:
      dispatch in interface org.j7m.middleware.transport.api.RuntimeTransportContext
    • dispatchTrusted

      public org.j7m.middleware.codec.api.EncodedValue dispatchTrusted(org.j7m.middleware.api.ObjectRef target, org.j7m.middleware.transport.api.MethodDescriptor method, List<org.j7m.middleware.codec.api.EncodedValue> arguments, org.j7m.middleware.api.InvocationOptions options, org.j7m.middleware.security.api.SecurityContext trustedContext)
      Specified by:
      dispatchTrusted in interface org.j7m.middleware.transport.api.RuntimeTransportContext
    • dispatchLogicalAsyncTrusted

      public org.j7m.middleware.codec.api.EncodedValue dispatchLogicalAsyncTrusted(org.j7m.middleware.api.ObjectRef target, org.j7m.middleware.transport.api.MethodDescriptor method, List<org.j7m.middleware.codec.api.EncodedValue> arguments, org.j7m.middleware.api.InvocationOptions options, org.j7m.middleware.security.api.SecurityContext trustedContext, org.j7m.middleware.transport.api.InvocationCancellation cancellation)
      Specified by:
      dispatchLogicalAsyncTrusted in interface org.j7m.middleware.transport.api.RuntimeTransportContext
    • exportCallback

      public org.j7m.middleware.api.ObjectRef exportCallback(Object value, Class<?> declaredType)
      Specified by:
      exportCallback in interface org.j7m.middleware.transport.api.RuntimeTransportContext
    • proxyFor

      public <T> T proxyFor(org.j7m.middleware.api.ObjectRef ref, Class<T> api)
      Specified by:
      proxyFor in interface org.j7m.middleware.transport.api.RuntimeTransportContext
    • reference

      public <T> T reference(org.j7m.middleware.api.ObjectRef reference, Class<T> contract, org.j7m.middleware.api.ProxyOptions options)
      Specified by:
      reference in interface org.j7m.middleware.api.MiddlewareRuntime
    • validateTarget

      public void validateTarget(org.j7m.middleware.api.ObjectRef target, String requiredInterface)
      Specified by:
      validateTarget in interface org.j7m.middleware.transport.api.RuntimeTransportContext
    • describeTarget

      public List<String> describeTarget(org.j7m.middleware.api.ObjectRef target)
      Specified by:
      describeTarget in interface org.j7m.middleware.transport.api.RuntimeTransportContext
    • releaseInvocationCallbacks

      public void releaseInvocationCallbacks(List<org.j7m.middleware.codec.api.EncodedValue> encodedArguments)
      Specified by:
      releaseInvocationCallbacks in interface org.j7m.middleware.transport.api.RuntimeTransportContext
    • executeOneWay

      public void executeOneWay(Runnable task)
      Specified by:
      executeOneWay in interface org.j7m.middleware.transport.api.RuntimeTransportContext