Package anbxj
Class Channel_JavaFramedSerializer
java.lang.Object
anbxj.Channel_JavaFramedSerializer
- All Implemented Interfaces:
Channel_MessageSerializer
A
Channel_MessageSerializer that delegates to standard Java object
serialisation via the utility methods in Crypto_SerializationUtils.
This serializer does not provide per-step message schemas - every protocol object is serialised as an opaque blob using Java serialisation, exactly as the traditional unstyled channels do. It is intended for situations where a length-delimited wire format is desired without adopting a schema-based format like Protocol Buffers.
Because it uses the same Java serialisation as the existing channels, the wire content is identical; only the framing (a varint length prefix) differs.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Channel_JavaFramedSerializerA shared, thread-safe instance (the class has no state). -
Method Summary
Modifier and TypeMethodDescriptiondeserialize(byte[] data, int step) Deserializes a byte array back into a logical protocol message object.byte[]Serializes a logical protocol message into a byte array.Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface anbxj.Channel_MessageSerializer
setSession
-
Field Details
-
INSTANCE
A shared, thread-safe instance (the class has no state).
-
-
Method Details
-
serialize
Description copied from interface:Channel_MessageSerializerSerializes a logical protocol message into a byte array.- Specified by:
serializein interfaceChannel_MessageSerializer- Parameters:
message- the object to send; the concrete type depends on the protocol step (e.g.,String,Crypto_SealedPair,Object[]for tuples)step- the protocol step number (starting from 1), used to identify the message format- Returns:
- the serialized bytes, ready to be written to the network
- Throws:
IOException- if serialization fails
-
deserialize
Description copied from interface:Channel_MessageSerializerDeserializes a byte array back into a logical protocol message object.- Specified by:
deserializein interfaceChannel_MessageSerializer- Parameters:
data- the raw bytes received from the networkstep- the expected protocol step number, used to identify the message format and recreate the appropriate object- Returns:
- the reconstructed protocol object (e.g.,
String,Crypto_SealedPair,Object[]) - Throws:
IOException- if deserialization failsClassNotFoundException- if a required class cannot be found (may occur when internal Java serialization is used inside cryptographic wrappers)
-