Class ManagedPayloadCodec

java.lang.Object
org.j7m.middleware.application.distributed.ManagedPayloadCodec

public final class ManagedPayloadCodec extends Object
Deterministic version-one data-only frames for durable invocation fingerprints and replay. The borrowed codec and schema functions must be thread-safe and free of external effects. References, callbacks, exceptions and control capabilities are rejected. The shared internal engine also serves partition state, but this public facade always enforces the native12KiB cap.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Largest binary frame whose base64 representation fits the native16KiB result field.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ManagedPayloadCodec(org.j7m.middleware.codec.api.ValueCodec codec, org.j7m.middleware.codec.api.SchemaRegistry schemas)
    Creates a data frame codec with the native maximum frame size.
    ManagedPayloadCodec(org.j7m.middleware.codec.api.ValueCodec codec, org.j7m.middleware.codec.api.SchemaRegistry schemas, int maximumBytes)
    Creates a codec with a stricter host byte limit; all frames include their format headers.
  • Method Summary

    Modifier and Type
    Method
    Description
    decode(byte[] frame, Class<?> type)
    Fully validates a frame and its schema allowlist before invoking the borrowed value decoder.
    byte[]
    encode(Object value, Class<?> type)
    Encodes an explicitly declared data value; maps and metadata use sorted string keys.
    inputHash(org.j7m.middleware.application.api.ManagedServiceContract contract, List<Class<?>> types, Object[] arguments)
    Fingerprints one complete method's ordered business inputs using the same canonical framing.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_FRAME_BYTES

      public static final int MAX_FRAME_BYTES
      Largest binary frame whose base64 representation fits the native16KiB result field.
      See Also:
  • Constructor Details

    • ManagedPayloadCodec

      public ManagedPayloadCodec(org.j7m.middleware.codec.api.ValueCodec codec, org.j7m.middleware.codec.api.SchemaRegistry schemas)
      Creates a data frame codec with the native maximum frame size.
      Parameters:
      codec - borrowed thread-safe value codec; its schema functions must have no external effects
      schemas - explicit allowlist, including any supported previous wire versions
      Throws:
      NullPointerException - if a collaborator is null
    • ManagedPayloadCodec

      public ManagedPayloadCodec(org.j7m.middleware.codec.api.ValueCodec codec, org.j7m.middleware.codec.api.SchemaRegistry schemas, int maximumBytes)
      Creates a codec with a stricter host byte limit; all frames include their format headers. UTF16 code units are length-framed, preserving Java strings without lossy surrogate replacement.
      Parameters:
      codec - borrowed trusted codec
      schemas - explicit schema allowlist
      maximumBytes - positive frame cap, at most12288 bytes
      Throws:
      NullPointerException - if a collaborator is null
      IllegalArgumentException - if the frame cap is invalid
  • Method Details

    • encode

      public byte[] encode(Object value, Class<?> type)
      Encodes an explicitly declared data value; maps and metadata use sorted string keys.
      Parameters:
      value - nullable data value
      type - explicit declared Java data type, never a frame-provided class name
      Returns:
      owned version-one frame, bounded by the configured cap
      Throws:
      org.j7m.middleware.api.MiddlewareException - with CODEC_ERROR for unsupported types, invalid schemas or bounds
    • decode

      public Object decode(byte[] frame, Class<?> type)
      Fully validates a frame and its schema allowlist before invoking the borrowed value decoder.
      Parameters:
      frame - complete version-one frame; trailing bytes are rejected
      type - explicitly trusted expected Java data type
      Returns:
      decoded value, possibly null for a nullable/void result
      Throws:
      org.j7m.middleware.api.MiddlewareException - with CODEC_ERROR for corruption, unsupported data or incompatible types
    • inputHash

      public String inputHash(org.j7m.middleware.application.api.ManagedServiceContract contract, List<Class<?>> types, Object[] arguments)
      Fingerprints one complete method's ordered business inputs using the same canonical framing. No target, trace carrier, deadline, physical attempt or principal is added to the input hash; authenticated tenant/principal identity belongs to the separate durable key scope.
      Parameters:
      contract - stable service ID/version and full erased method identity
      types - explicit parameter classes matching the method signature
      arguments - ordered values, including a declared business key parameter when present
      Returns:
      lowercase SHA-256 digest of version-one canonical business input bytes
      Throws:
      org.j7m.middleware.api.MiddlewareException - with CODEC_ERROR for a signature mismatch or unsupported/bounded input