@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 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; }
@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; }
@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); }
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()); } }
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 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); }