// Path: zing-common/src/main/java/org/zxc/zing/common/serialize/Serializer.java
// public class Serializer {
// 
//     private static final Logger log = LoggerFactory.getLogger(Serializer.class);
// 
// 
//     public static byte[] serialize(Object obj) throws IOException {
//         ByteArrayOutputStream bos = new ByteArrayOutputStream();
//         Hessian2Output out = new Hessian2Output(bos);
//         out.writeObject(obj);
//         out.close();
//         return bos.toByteArray();
//     }
// 
//     public static Object deserialize(byte[] data) throws IOException {
//         ByteArrayInputStream bis = new ByteArrayInputStream(data);
//         Hessian2Input in = new Hessian2Input(bis);
//         return in.readObject();
//     }
// }


import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zxc.zing.common.serialize.Serializer;
package org.zxc.zing.common.handler;


/**
 * Created by xuanchen.zhao on 15-12-15.
 */
public class NettyEncoder extends MessageToByteEncoder {

    private static final Logger log = LoggerFactory.getLogger(NettyEncoder.class);

    @Override
    protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception {

        log.info("encoding start");

// Path: zing-common/src/main/java/org/zxc/zing/common/serialize/Serializer.java
// public class Serializer {
// 
//     private static final Logger log = LoggerFactory.getLogger(Serializer.class);
// 
// 
//     public static byte[] serialize(Object obj) throws IOException {
//         ByteArrayOutputStream bos = new ByteArrayOutputStream();
//         Hessian2Output out = new Hessian2Output(bos);
//         out.writeObject(obj);
//         out.close();
//         return bos.toByteArray();
//     }
// 
//     public static Object deserialize(byte[] data) throws IOException {
//         ByteArrayInputStream bis = new ByteArrayInputStream(data);
//         Hessian2Input in = new Hessian2Input(bis);
//         return in.readObject();
//     }
// }


// Path: zing-common/src/main/java/org/zxc/zing/common/handler/NettyEncoder.java
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zxc.zing.common.serialize.Serializer;

package org.zxc.zing.common.handler;


/**
 * Created by xuanchen.zhao on 15-12-15.
 */
public class NettyEncoder extends MessageToByteEncoder {

    private static final Logger log = LoggerFactory.getLogger(NettyEncoder.class);

    @Override
    protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception {

        log.info("encoding start");

        byte[] bytes = Serializer.serialize(msg);