class SofaHessianSerializer extends AbstractSerializer {

    @Override
    public AbstractByteBuf encode(Object object, Map<String, String> context) {

        CustomHessianSerializer serializer = getCustomSerializer(object);
        if (serializer != null) {
            return serializer.encodeObject(object, context);
        } else {
            UnsafeByteArrayOutputStream byteArray = new UnsafeByteArrayOutputStream();
            Hessian2Output output = new Hessian2Output(byteArray);
            try {
                output.setSerializerFactory(serializerFactory);
                output.writeObject(object);
                output.close();
                return new ByteStreamWrapperByteBuf(byteArray);
            } catch (Exception e) {
                throw buildSerializeError(e.getMessage(), e);
            }

        }
    }

    public  SofaHessianSerializer();

}