@Override public void serialize(final OutputStream output, final Object object) { Hessian2Output ho = new Hessian2Output(output); try { ho.startMessage(); ho.writeObject(object); ho.completeMessage(); ho.close(); output.close(); } catch (IOException e) { e.printStackTrace(); } }
@Override public byte[] serialize(Object obj) throws Exception { UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(); Hessian2Output out = new Hessian2Output(bos); out.startMessage(); out.writeObject(obj); out.completeMessage(); out.close(); return bos.toByteArray(); }
@Override public byte[] serialize(Object obj) throws Exception { UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(); Hessian2Output out = new Hessian2Output(bos); out.startMessage(); out.writeObject(obj); out.completeMessage(); out.close(); return bos.toByteArray(); }
@Override public byte[] serialize(Object obj) throws Exception { ByteArrayOutputStream bos = new ByteArrayOutputStream(); Hessian2Output out = new Hessian2Output(bos); out.startMessage(); out.writeObject(obj); out.completeMessage(); out.close(); bos.close(); return bos.toByteArray(); }
public static byte[] toByteArray(Object object) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); Hessian2Output out = new Hessian2Output(bos); out.startMessage(); out.writeObject(object); out.completeMessage(); out.flush(); return bos.toByteArray(); } catch (IOException e) { throw new IllegalStateException(e); } }
@Override public void serialize(OutputStream output, Object object) { Hessian2Output ho = new Hessian2Output(output); try { ho.startMessage(); ho.writeObject(object); ho.completeMessage(); ho.close(); output.close(); } catch (IOException e) { e.printStackTrace(); } }
public void pack() { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); Hessian2Output out = new Hessian2Output(byteArrayOutputStream); try { out.startMessage(); out.writeObject(variationFailures); out.writeObject(variationResults); out.completeMessage(); out.close(); data = byteArrayOutputStream.toByteArray(); variationFailures.clear(); variationResults.clear(); } catch (IOException e) { // Should never happen for ByteArrayOutputStream. If happen - // something is broken. throw new IllegalStateException(e); } finally { if (byteArrayOutputStream != null) { try { byteArrayOutputStream.close(); } catch (IOException e) { } } } }
public void pack() { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); Hessian2Output out = new Hessian2Output(byteArrayOutputStream); try { out.startMessage(); out.writeObject(variationFailures); out.writeObject(variationResults); out.completeMessage(); out.close(); data = byteArrayOutputStream.toByteArray(); variationFailures.clear(); variationResults.clear(); } catch (IOException e) { // Should never happen for ByteArrayOutputStream. If happen - // something is broken. throw new IllegalStateException(e); } finally { if (byteArrayOutputStream != null) { try { byteArrayOutputStream.close(); } catch (IOException e) { } } } }
public static byte[] serialize( Serializable serializable ) throws IOException { // Initialize buffer and converter ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); Hessian2Output hessian2Output = new Hessian2Output( byteArrayOutputStream ); hessian2Output.setSerializerFactory( new SerializerFactory( SerializeUtil.class.getClassLoader() ) ); // Serialize objects hessian2Output.startMessage(); if (serializable instanceof Character) { // Hessian doesn't properly serialize java.lang.Character serializable = new CharWrapper((Character)serializable); } hessian2Output.writeObject( serializable ); hessian2Output.completeMessage(); hessian2Output.close(); return byteArrayOutputStream.toByteArray(); }
@Override public void marshal(final Exchange exchange, final Object graph, final OutputStream outputStream) throws Exception { final Hessian2Output out = new Hessian2Output(outputStream); try { out.startMessage(); out.writeObject(graph); out.completeMessage(); } finally { out.flush(); try { out.close(); } catch (IOException e) { // ignore } } }
@Override public byte[] serialize(Object obj) throws Exception { UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(); Hessian2Output out = new Hessian2Output(bos); out.startMessage(); out.writeObject(obj); out.completeMessage(); out.close(); return bos.toByteArray(); }