HessianSerializer extends AbstractSerializerAdapter { @Override public byte[] serialize(Object object, ClassLoader classLoader) throws SerializeException { ByteArrayOutputStream byteArray = new ByteArrayOutputStream(); Hessian2Output output = new Hessian2Output(byteArray); output.setSerializerFactory(getFactory(classLoader)); try { output.writeObject(object); output.close(); } catch (Throwable t) { throw new SerializeException("[Error-1001]-hessian-serialize-error", t); } return byteArray.toByteArray(); }  @Override Type type(); @Override byte[] serialize(Object object, ClassLoader classLoader); @Override @SuppressWarnings("unchecked") T deserialize(byte[] bytes, Class<T> type, ClassLoader classLoader); @Override Object deserialize(byte[] bytes);  }
@Test public void serialize() { HessianSerializeDomain domain = new HessianSerializeDomain(); Serializer serializer = SerializerProvider.instance().provide(Serializer.Type.HESSIAN); String sequence; try { sequence = serializer.serialize2String(domain); Assert.assertNotNull(sequence); HessianSerializeDomain deserialize = serializer.deserialize(sequence, HessianSerializeDomain.class); Assert.assertEquals(domain, deserialize); } catch (SerializeException e) { Assert.fail(e.getMessage()); } }