public abstract class Iced<D extends Iced> extends java.lang.Object implements Freezable<D>, java.io.Externalizable
Auto-serializer base-class using a delegator pattern (the faster option is to byte-code gen directly in all Iced classes, but this requires all Iced classes go through a ClassLoader).
Iced is a marker class, and Freezable
is the companion marker
interface. Marked classes have 2-byte integer type associated with them,
and an auto-genned delegate class created to actually do byte-stream and
JSON serialization and deserialization. Byte-stream serialization is
extremely dense (includes various compressions), and typically memory-bandwidth
bound to generate.
During startup time the Weaver creates a parallel set of classes called (classname)$Icer. These provide bytestream and JSON serializers and deserializers which get called by AutoBuffer.write* and AutoBuffer.read*.
To debug the automagic serialization code create a transient field in your Iced class called DEBUG_WEAVER. The generated source code will get written to STDOUT:
transient int DEBUG_WEAVER = 1;
Freezable
,
Weaver
,
AutoBuffer
,
Serialized FormConstructor and Description |
---|
Iced() |
Modifier and Type | Method and Description |
---|---|
byte[] |
asBytes()
Return serialized version of self as a byte array.
|
D |
clone()
Clone, without the annoying exception
|
protected void |
copyOver(D src)
Copy over cloned instance 'src' over 'this', field by field.
|
int |
frozenType()
Returns a small dense integer, which is cluster-wide unique per-class.
|
D |
read(AutoBuffer ab)
Standard "read thyself from the AutoBuffer" call, using the fast Iced protocol.
|
void |
readExternal(java.io.ObjectInput ois)
Implementation of the
Iced serialization protocol, only called by
auto-genned code. |
D |
readJSON(AutoBuffer ab)
Standard "read thyself from the AutoBuffer" call, using JSON.
|
D |
reloadFromBytes(byte[] ary)
Replace yourself with deserialized version from the given bytes.
|
byte[] |
toJsonBytes() |
java.lang.String |
toJsonString()
Helper for folks that want a JSON String for this object.
|
AutoBuffer |
write(AutoBuffer ab)
Standard "write thyself into the AutoBuffer" call, using the fast Iced
protocol.
|
void |
writeExternal(java.io.ObjectOutput oos) |
AutoBuffer |
writeJSON(AutoBuffer ab)
Standard "write thyself into the AutoBuffer" call, using JSON.
|
public byte[] asBytes()
Freezable
public D reloadFromBytes(byte[] ary)
Freezable
reloadFromBytes
in interface Freezable<D extends Iced>
ary
- byte array containing exactly (i.e. nothing else) the serialized version of the Freezablepublic final AutoBuffer write(AutoBuffer ab)
Icer
classes.write
in interface Freezable<D extends Iced>
ab
- AutoBuffer
to write this object to.AutoBuffer
for flow-coding.public AutoBuffer writeJSON(AutoBuffer ab)
Icer
classes.writeJSON
in interface Freezable<D extends Iced>
ab
- AutoBuffer
to write this object to.AutoBuffer
for flow-coding.public final D read(AutoBuffer ab)
Icer
classes.read
in interface Freezable<D extends Iced>
ab
- AutoBuffer
to read this object from.AutoBuffer
for flow-coding.public final D readJSON(AutoBuffer ab)
Icer
classes.readJSON
in interface Freezable<D extends Iced>
ab
- AutoBuffer
to read this object from.AutoBuffer
for flow-coding.public final java.lang.String toJsonString()
public final byte[] toJsonBytes()
public final int frozenType()
frozenType
in interface Freezable<D extends Iced>
public final D clone()
protected void copyOver(D src)
public void readExternal(java.io.ObjectInput ois) throws java.io.IOException, java.lang.ClassNotFoundException
Iced
serialization protocol, only called by
auto-genned code. Not intended to be called by user code. Override only
for custom Iced serializers.readExternal
in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException
public void writeExternal(java.io.ObjectOutput oos) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
java.io.IOException