@Override public byte[] serializeMulti(Object[] data) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); Hessian2Output out = new Hessian2Output(bos); for(Object obj: data){ out.writeObject(obj); } out.flush(); return bos.toByteArray(); }
@Override public byte[] serialize(Object data) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); Hessian2Output out = new Hessian2Output(bos); out.writeObject(data); out.flush(); return bos.toByteArray(); }
@Override public byte[] serialize(final Object obj) throws HmilyException { Hessian2Output hos; try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { hos = new Hessian2Output(bos); hos.writeObject(obj); hos.flush(); return bos.toByteArray(); } catch (IOException ex) { throw new HmilyException("Hessian serialize error " + ex.getMessage()); } }
@Override public byte[] serialize(final Object obj) throws TransactionException { Hessian2Output hos; try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { hos = new Hessian2Output(bos); hos.writeObject(obj); hos.flush(); return bos.toByteArray(); } catch (IOException ex) { throw new TransactionException("Hessian serialize error " + ex.getMessage()); } }
@Override public byte[] serialize(final Object obj) throws MythException { Hessian2Output hos; try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { hos = new Hessian2Output(bos); hos.writeObject(obj); hos.flush(); return bos.toByteArray(); } catch (IOException ex) { throw new MythException("Hessian serialize error " + ex.getMessage()); } }
@Override public <T> OutputBuf writeObject(OutputBuf outputBuf, T obj) { Hessian2Output output = Outputs.getOutput(outputBuf); try { output.writeObject(obj); output.flush(); return outputBuf; } catch (IOException e) { ThrowUtil.throwException(e); } finally { try { output.close(); } catch (IOException ignored) {} } return null; // never get here }
@Override public <T> OutputBuf writeObject(OutputBuf outputBuf, T obj) { Hessian2Output output = Outputs.getOutput(outputBuf); try { output.writeObject(obj); output.flush(); return outputBuf; } catch (IOException e) { ThrowUtil.throwException(e); } finally { try { output.close(); } catch (IOException ignored) {} } return null; // never get here }
@Override public <T> byte[] writeObject(T obj) { ByteArrayOutputStream buf = OutputStreams.getByteArrayOutputStream(); Hessian2Output output = Outputs.getOutput(buf); try { output.writeObject(obj); output.flush(); return buf.toByteArray(); } catch (IOException e) { ThrowUtil.throwException(e); } finally { try { output.close(); } catch (IOException ignored) {} OutputStreams.resetBuf(buf); } return null; // never get here }
@Override public <T> byte[] writeObject(T obj) { ByteArrayOutputStream buf = OutputStreams.getByteArrayOutputStream(); Hessian2Output output = Outputs.getOutput(buf); try { output.writeObject(obj); output.flush(); return buf.toByteArray(); } catch (IOException e) { ThrowUtil.throwException(e); } finally { try { output.close(); } catch (IOException ignored) {} OutputStreams.resetBuf(buf); } return null; // never get here }
@Override public byte[] serialize(Object data) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); Hessian2Output out = new Hessian2Output(bos); out.writeObject(data); out.flush(); return bos.toByteArray(); }
@Override public byte[] serializeMulti(Object[] data) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); Hessian2Output out = new Hessian2Output(bos); for(Object obj: data){ out.writeObject(obj); } out.flush(); return bos.toByteArray(); }
@Override public byte[] serialize(final Object obj) { Hessian2Output hos; try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { hos = new Hessian2Output(bos); hos.writeObject(obj); hos.flush(); return bos.toByteArray(); } catch (IOException ex) { throw new SerializerException("Hessian serialize error " + ex.getMessage()); } }
BytesOutputStream() throws IOException { if (SIZE < _offset + 16) { Hessian2Output.this.flush(); } _startOffset = _offset; _offset += 3; // skip 'b' xNN xNN }
/** * Flushes the output. */ public void flush() throws IOException { _out.flush(); }
/** * Writes the tail of the map to the stream. */ public void writeMapEnd() throws IOException { if (SIZE < _offset + 32) flush(); _buffer[_offset++] = (byte) BC_END; }
public void endStreamingPacket() throws IOException { int len = _offset - 3; _buffer[0] = (byte) 'P'; _buffer[1] = (byte) (len >> 8); _buffer[2] = (byte) len; _isStreaming = false; flush(); }
public final void close() throws IOException { // hessian/3a8c flush(); OutputStream os = _os; _os = null; if (os != null) { if (_isCloseStreamOnClose) os.close(); } }
@Override public void flush() { Hessian2Output out = _out; if (out != null) { try { out.flush(); } catch (IOException e) { log.log(Level.FINEST, e.toString(), e); } } }
@Override public void encodeResponse(OutputStream outputStream, RpcResponse result) throws IOException { Hessian2Output out = new Hessian2Output(outputStream); out.writeObject(result); out.flush(); }
@Override public void encodeRequest(OutputStream outputStream, RpcRequest request) throws IOException { Hessian2Output out = new Hessian2Output(outputStream); out.writeObject(request); out.flush(); }