@Override public Object deserialize(final InputStream input) { Object result = null; try { Hessian2Input hi = new Hessian2Input(input); hi.startMessage(); result = hi.readObject(); hi.completeMessage(); hi.close(); input.close(); } catch (IOException e) { e.printStackTrace(); } return result; }
@SuppressWarnings("unchecked") @Override public <T> T deserialize(byte[] data, Class<T> clazz) throws Exception { UnsafeByteArrayInputStream bin = new UnsafeByteArrayInputStream(data); Hessian2Input in = new Hessian2Input(bin); in.startMessage(); Object obj = in.readObject(clazz); in.completeMessage(); in.close(); return (T) obj; }
@SuppressWarnings("unchecked") @Override public <T> T deserialize(byte[] data, Class<T> clazz) throws Exception { UnsafeByteArrayInputStream bin = new UnsafeByteArrayInputStream(data); Hessian2Input in = new Hessian2Input(bin); in.startMessage(); Object obj = in.readObject(clazz); in.completeMessage(); in.close(); return (T) obj; }
public static Object toObject(byte[] bytes) { try { Hessian2Input in = new Hessian2Input(new ByteArrayInputStream(bytes)); in.startMessage(); Object object = in.readObject(); in.completeMessage(); return object; } catch (IOException e) { throw new IllegalStateException(e); } }
@Override public <T> T deserialize(byte[] data, Class<T> clazz) throws Exception { ByteArrayInputStream bin = new ByteArrayInputStream(data); Hessian2Input in = new Hessian2Input(bin); in.startMessage(); Object obj = in.readObject(); in.completeMessage(); in.close(); bin.close(); return (T) obj; }
@Override public Object deserialize(InputStream input) { Object result = null; try { Hessian2Input hi = new Hessian2Input(input); hi.startMessage(); result = hi.readObject(); hi.completeMessage(); hi.close(); input.close(); } catch (IOException e) { e.printStackTrace(); } return result; } }
public static Serializable deserialize(byte[] dataBytes) throws IOException { Hessian2Input hessian2Input = new Hessian2Input( new ByteArrayInputStream( dataBytes ) ); hessian2Input.setSerializerFactory( new SerializerFactory( SerializeUtil.class.getClassLoader() ) ); // Convert hessian2Input.startMessage(); Serializable serializable = (Serializable)hessian2Input.readObject(); if (serializable instanceof CharWrapper) { serializable = ((CharWrapper)serializable).charValue(); } hessian2Input.completeMessage(); hessian2Input.close(); // Return strings return serializable; } }
@SuppressWarnings("unchecked") public void unpack() throws IOException { if (data != null) { ByteArrayInputStream byteInputStream = new ByteArrayInputStream(data); Hessian2Input input = new Hessian2Input(byteInputStream); try { input.startMessage(); variationFailures = (Map<String, String>) input.readObject(); variationResults = (Map<String, T>) input.readObject(); input.completeMessage(); input.close(); } catch (IOException e) { throw e; } finally { if (byteInputStream != null) { try { byteInputStream.close(); } catch (IOException e) { } } } } }
@SuppressWarnings("unchecked") public void unpack() throws IOException { if (data != null) { ByteArrayInputStream byteInputStream = new ByteArrayInputStream(data); Hessian2Input input = new Hessian2Input(byteInputStream); try { input.startMessage(); variationFailures = (Map<String, String>) input.readObject(); variationResults = (Map<String, T>) input.readObject(); input.completeMessage(); input.close(); } catch (IOException e) { throw e; } finally { if (byteInputStream != null) { try { byteInputStream.close(); } catch (IOException e) { } } } } }
@SuppressWarnings("unchecked") @Override public <T> T deserialize(byte[] data, Class<T> clazz) throws Exception { UnsafeByteArrayInputStream bin = new UnsafeByteArrayInputStream(data); Hessian2Input in = new Hessian2Input(bin); in.startMessage(); Object obj = in.readObject(clazz); in.completeMessage(); in.close(); return (T) obj; }
@Override public Object unmarshal(final Exchange exchange, final InputStream inputStream) throws Exception { final Hessian2Input in; if (!whitelistEnabled) { in = new Hessian2Input(inputStream); } else { HessianFactory factory = new HessianFactory(); if (ObjectHelper.isNotEmpty(allowedUnmarshallObjects)) { factory.allow(allowedUnmarshallObjects); } if (ObjectHelper.isNotEmpty(deniedUnmarshallObjects)) { factory.deny(deniedUnmarshallObjects); } in = factory.createHessian2Input(inputStream); } try { in.startMessage(); final Object obj = in.readObject(); in.completeMessage(); return obj; } finally { try { in.close(); } catch (IOException e) { // ignore } } }