@Override public void write(ObjectDataOutput out, Portable p) throws IOException { if (!(out instanceof BufferObjectDataOutput)) { throw new IllegalArgumentException("ObjectDataOutput must be instance of BufferObjectDataOutput!"); } if (p.getClassId() == 0) { throw new IllegalArgumentException("Portable class ID cannot be zero!"); } out.writeInt(p.getFactoryId()); out.writeInt(p.getClassId()); writeInternal((BufferObjectDataOutput) out, p); }
@Override public ClassDefinition lookupOrRegisterClassDefinition(Portable p) throws IOException { int portableVersion = SerializationUtil.getPortableVersion(p, version); ClassDefinition cd = lookupClassDefinition(p.getFactoryId(), p.getClassId(), portableVersion); if (cd == null) { ClassDefinitionWriter writer = new ClassDefinitionWriter(this, p.getFactoryId(), p.getClassId(), portableVersion); p.writePortable(writer); cd = writer.registerAndGet(); } return cd; }
private ClassDefinition createNestedClassDef(Portable portable, ClassDefinitionBuilder nestedBuilder) throws IOException { ClassDefinitionWriter writer = new ClassDefinitionWriter(context, nestedBuilder); portable.writePortable(writer); return context.registerClassDefinition(nestedBuilder.build()); }
private Portable read(BufferObjectDataInput in, int factoryId, int classId) throws IOException { int version = in.readInt(); Portable portable = createNewPortableInstance(factoryId, classId); int portableVersion = findPortableVersion(factoryId, classId, portable); DefaultPortableReader reader = createReader(in, factoryId, classId, version, portableVersion); portable.readPortable(reader); reader.end(); return portable; }
private ClassDefinition createNestedClassDef(Portable portable, ClassDefinitionBuilder nestedBuilder) throws IOException { ClassDefinitionWriter writer = new ClassDefinitionWriter(context, nestedBuilder); portable.writePortable(writer); return context.registerClassDefinition(nestedBuilder.build()); }
private Portable read(BufferObjectDataInput in, int factoryId, int classId) throws IOException { int version = in.readInt(); Portable portable = createNewPortableInstance(factoryId, classId); int portableVersion = findPortableVersion(factoryId, classId, portable); DefaultPortableReader reader = createReader(in, factoryId, classId, version, portableVersion); portable.readPortable(reader); reader.end(); return portable; }
@Override public void write(ObjectDataOutput out, Portable p) throws IOException { if (!(out instanceof BufferObjectDataOutput)) { throw new IllegalArgumentException("ObjectDataOutput must be instance of BufferObjectDataOutput!"); } if (p.getClassId() == 0) { throw new IllegalArgumentException("Portable class ID cannot be zero!"); } out.writeInt(p.getFactoryId()); out.writeInt(p.getClassId()); writeInternal((BufferObjectDataOutput) out, p); }
@Override public ClassDefinition lookupOrRegisterClassDefinition(Portable p) throws IOException { int portableVersion = SerializationUtil.getPortableVersion(p, version); ClassDefinition cd = lookupClassDefinition(p.getFactoryId(), p.getClassId(), portableVersion); if (cd == null) { ClassDefinitionWriter writer = new ClassDefinitionWriter(this, p.getFactoryId(), p.getClassId(), portableVersion); p.writePortable(writer); cd = writer.registerAndGet(); } return cd; }
void writeInternal(BufferObjectDataOutput out, Portable p) throws IOException { ClassDefinition cd = context.lookupOrRegisterClassDefinition(p); out.writeInt(cd.getVersion()); DefaultPortableWriter writer = new DefaultPortableWriter(this, out, cd); p.writePortable(writer); writer.end(); }
private void checkPortableAttributes(FieldDefinition fd, Portable portable) { if (fd.getFactoryId() != portable.getFactoryId()) { throw new HazelcastSerializationException("Wrong Portable type! Generic portable types are not supported! " + " Expected factory-id: " + fd.getFactoryId() + ", Actual factory-id: " + portable.getFactoryId()); } if (fd.getClassId() != portable.getClassId()) { throw new HazelcastSerializationException("Wrong Portable type! Generic portable types are not supported! " + "Expected class-id: " + fd.getClassId() + ", Actual class-id: " + portable.getClassId()); } }
void writeInternal(BufferObjectDataOutput out, Portable p) throws IOException { ClassDefinition cd = context.lookupOrRegisterClassDefinition(p); out.writeInt(cd.getVersion()); DefaultPortableWriter writer = new DefaultPortableWriter(this, out, cd); p.writePortable(writer); writer.end(); }
private void checkPortableAttributes(FieldDefinition fd, Portable portable) { if (fd.getFactoryId() != portable.getFactoryId()) { throw new HazelcastSerializationException("Wrong Portable type! Generic portable types are not supported! " + " Expected factory-id: " + fd.getFactoryId() + ", Actual factory-id: " + portable.getFactoryId()); } if (fd.getClassId() != portable.getClassId()) { throw new HazelcastSerializationException("Wrong Portable type! Generic portable types are not supported! " + "Expected class-id: " + fd.getClassId() + ", Actual class-id: " + portable.getClassId()); } }
@Override public void writePortableArray(String fieldName, Portable[] portables) throws IOException { if (portables == null || portables.length == 0) { throw new HazelcastSerializationException("Cannot write null portable array without explicitly " + "registering class definition!"); } Portable p = portables[0]; int classId = p.getClassId(); for (int i = 1; i < portables.length; i++) { if (portables[i].getClassId() != classId) { throw new IllegalArgumentException("Detected different class-ids in portable array!"); } } int version = SerializationUtil.getPortableVersion(p, context.getVersion()); ClassDefinition nestedClassDef = createNestedClassDef(p, new ClassDefinitionBuilder(p.getFactoryId(), classId, version)); builder.addPortableArrayField(fieldName, nestedClassDef); }
@Override public void writePortableArray(String fieldName, Portable[] portables) throws IOException { if (portables == null || portables.length == 0) { throw new HazelcastSerializationException("Cannot write null portable array without explicitly " + "registering class definition!"); } Portable p = portables[0]; int classId = p.getClassId(); for (int i = 1; i < portables.length; i++) { if (portables[i].getClassId() != classId) { throw new IllegalArgumentException("Detected different class-ids in portable array!"); } } int version = SerializationUtil.getPortableVersion(p, context.getVersion()); ClassDefinition nestedClassDef = createNestedClassDef(p, new ClassDefinitionBuilder(p.getFactoryId(), classId, version)); builder.addPortableArrayField(fieldName, nestedClassDef); }
@Override public void writePortable(String fieldName, Portable portable) throws IOException { if (portable == null) { throw new HazelcastSerializationException("Cannot write null portable without explicitly " + "registering class definition!"); } int version = SerializationUtil.getPortableVersion(portable, context.getVersion()); ClassDefinition nestedClassDef = createNestedClassDef(portable, new ClassDefinitionBuilder(portable.getFactoryId(), portable.getClassId(), version)); builder.addPortableField(fieldName, nestedClassDef); }
@Override public void writePortable(String fieldName, Portable portable) throws IOException { if (portable == null) { throw new HazelcastSerializationException("Cannot write null portable without explicitly " + "registering class definition!"); } int version = SerializationUtil.getPortableVersion(portable, context.getVersion()); ClassDefinition nestedClassDef = createNestedClassDef(portable, new ClassDefinitionBuilder(portable.getFactoryId(), portable.getClassId(), version)); builder.addPortableField(fieldName, nestedClassDef); }