Search in sources :

Example 1 with TypedDataSerializable

use of com.hazelcast.nio.serialization.TypedDataSerializable in project hazelcast by hazelcast.

the class DataSerializableSerializer method write.

@Override
public void write(ObjectDataOutput out, DataSerializable obj) throws IOException {
    // If you ever change the way this is serialized think about to change
    // BasicOperationService::extractOperationCallId
    final boolean identified = obj instanceof IdentifiedDataSerializable;
    out.writeBoolean(identified);
    if (identified) {
        final IdentifiedDataSerializable ds = (IdentifiedDataSerializable) obj;
        out.writeInt(ds.getFactoryId());
        out.writeInt(ds.getId());
    } else {
        if (obj instanceof TypedDataSerializable) {
            out.writeUTF(((TypedDataSerializable) obj).getClassType().getName());
        } else {
            out.writeUTF(obj.getClass().getName());
        }
    }
    obj.writeData(out);
}
Also used : IdentifiedDataSerializable(com.hazelcast.nio.serialization.IdentifiedDataSerializable) TypedDataSerializable(com.hazelcast.nio.serialization.TypedDataSerializable)

Aggregations

IdentifiedDataSerializable (com.hazelcast.nio.serialization.IdentifiedDataSerializable)1 TypedDataSerializable (com.hazelcast.nio.serialization.TypedDataSerializable)1