java - Msgpack Generic serialization/desrialization -
i using msgpack integrated axon framework. on axon event handler object's on runtime can of type.as object type unknown, want use generic serialization/deserialiation. serialization done issue arises when deserialize byte stream. ex:
public <s, t> t deserialize(serializedobject<s> serializedobject) { byte[] serializedbytes= (byte[]) serializedobject.getdata(); object bytes = null; try { bytes=objectmapper.readvalue(serializedbytes,object.class); system.out.println("after deserialization : "+bytes); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } return (t) bytes; }
where serializedobject has custom method getdata() contains serialized bytes. here read value & give representation object.class
linkedhashmap
in return value target. there standard way perform generic serialization / deserialization object type using msgpack.
without type information won't possible deserialize object @ runtime using msgpack see here
Comments
Post a Comment