@Override
    public byte[] serialize(Object obj) throws CodecException {
        ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
        Hessian2Output output = new Hessian2Output(byteArray);
        output.setSerializerFactory(serializerFactory);
        try {
            output.writeObject(obj);
            output.close();
        } catch (IOException e) {
            throw new CodecException("IOException occurred when Hessian serializer encode!", e);
        }

        return byteArray.toByteArray();
    }
@ Override public byte [ ] serialize ( Object obj ) throws CodecException { ByteArrayOutputStream byteArray = new ByteArrayOutputStream ( ) ; Hessian2Output output = new Hessian2Output ( byteArray ) ; output . setSerializerFactory ( serializerFactory ) ; try { output . writeObject ( obj ) ; output . close ( ) ; } catch ( IOException e ) { throw new CodecException ( "IOException occurred when Hessian serializer encode!" , e ) ; } return byteArray . toByteArray ( ) ; }
@see com.alipay.remoting.serialization.Serializer#serialize(java.lang.Object)