static public HessianOutput createHessianOutput(OutputStream out) { HessianOutput hout = new HessianOutput(out); hout.setSerializerFactory(_serializerFactory); return hout; }
@Override public byte[] serialize(Object object) throws IOException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); HessianOutput out = new HessianOutput(bytes); out.setSerializerFactory(serializerFactory); out.writeObject(object); out.flush(); return bytes.toByteArray(); }
public static byte[] serialize(Object obj) throws IOException { if (obj == null) throw new NullPointerException(); SerializerFactory serializerFactory = new SerializerFactory(); serializerFactory.addFactory(new BigDecimalSerializerFactory()); ByteArrayOutputStream os = new ByteArrayOutputStream(); HessianOutput ho = new HessianOutput(os); ho.setSerializerFactory(serializerFactory); ho.writeObject(obj); return os.toByteArray(); }
@Override public void serialize(Object object, OutputStream outputStream) throws IOException { HessianOutput out = new HessianOutput(outputStream); out.setSerializerFactory(serializerFactory); out.writeObject(object); out.flush(); }
HessianCauchoOutput(OutputStream stream) { this.stream = stream; this.output = new HessianOutput(); output.setSerializerFactory(new JMXSerializerFactory()); output.init(stream); }
public static Object cloneViaServerClientSerialization( Serializable object, EntityResolver serverResolver) throws Exception { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); HessianOutput out = new HessianOutput(bytes); out.setSerializerFactory(HessianConfig.createFactory( HessianService.SERVER_SERIALIZER_FACTORIES, serverResolver)); out.writeObject(object); byte[] data = bytes.toByteArray(); HessianInput in = new HessianInput(new ByteArrayInputStream(data)); in.setSerializerFactory(HessianConfig.createFactory( HessianConnection.CLIENT_SERIALIZER_FACTORIES, null)); return in.readObject(); }
public static Object cloneViaServerClientSerialization( Serializable object, EntityResolver serverResolver) throws Exception { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); HessianOutput out = new HessianOutput(bytes); out.setSerializerFactory(HessianConfig.createFactory( HessianService.SERVER_SERIALIZER_FACTORIES, serverResolver)); out.writeObject(object); byte[] data = bytes.toByteArray(); HessianInput in = new HessianInput(new ByteArrayInputStream(data)); in.setSerializerFactory(HessianConfig.createFactory( HessianConnection.CLIENT_SERIALIZER_FACTORIES, null)); return in.readObject(); }
/** * A utility method that clones an object using Hessian serialization/deserialization * mechanism, which is different from default Java serialization. */ public static Object cloneViaClientServerSerialization( Serializable object, EntityResolver serverResolver) throws Exception { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); HessianOutput out = new HessianOutput(bytes); out.setSerializerFactory(HessianConfig.createFactory( HessianConnection.CLIENT_SERIALIZER_FACTORIES, null)); out.writeObject(object); byte[] data = bytes.toByteArray(); HessianInput in = new HessianInput(new ByteArrayInputStream(data)); in.setSerializerFactory(HessianConfig.createFactory( HessianService.SERVER_SERIALIZER_FACTORIES, serverResolver)); return in.readObject(); }
/** * A utility method that clones an object using Hessian serialization/deserialization * mechanism, which is different from default Java serialization. */ public static Object cloneViaClientServerSerialization( Serializable object, EntityResolver serverResolver) throws Exception { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); HessianOutput out = new HessianOutput(bytes); out.setSerializerFactory(HessianConfig.createFactory( HessianConnection.CLIENT_SERIALIZER_FACTORIES, null)); out.writeObject(object); byte[] data = bytes.toByteArray(); HessianInput in = new HessianInput(new ByteArrayInputStream(data)); in.setSerializerFactory(HessianConfig.createFactory( HessianService.SERVER_SERIALIZER_FACTORIES, serverResolver)); return in.readObject(); }
@Override protected void encode(ChannelHandlerContext ctx, Serializable msg, ByteBuf out) throws Exception { int startIdx = out.writerIndex(); ByteBufOutputStream bout = new ByteBufOutputStream(out); bout.write(LENGTH_PLACEHOLDER); // ObjectOutputStream oout = new CompactObjectOutputStream(bout); // oout.writeObject(msg); // oout.flush(); // oout.close(); HessianOutput hout = new HessianOutput(bout); hout.setSerializerFactory(SerializerFactoryUtil.getSerializerFactory()); hout.writeObject(msg); int endIdx = out.writerIndex(); out.setInt(startIdx, endIdx - startIdx - 4); } }
out.setSerializerFactory(getSerializerFactory()); out.init(os);
out.setSerializerFactory(getSerializerFactory()); out.init(os);