一、简介
JBoss Marshalling是一个Java对象序列化包,对JDK默认的序列化框架进行了优化,但又保持和java.io.Serializable接口的兼容。
二、Marshalling开发环境准备
1、下载类库
由于只涉及到Marshalling的序列化类库,因此只需要下载jboss-marshalling-1.3.0.CR9.jar和jboss-marshalling-serial-1.3.0.CR9.jar包即可,下载地址如下:https://www.jboss.org/jbossmarshalling/downloads
2、将下载的类库build到classpath下:
二、Netty的Marshalling开发
1、Marshalling编解码器工厂类:
import org.jboss.marshalling.MarshallerFactory;
import org.jboss.marshalling.Marshalling;
import org.jboss.marshalling.MarshallingConfiguration;
import io.netty.handler.codec.marshalling.DefaultMarshallerProvider;
import io.netty.handler.codec.marshalling.DefaultUnmarshallerProvider;
import io.netty.handler.codec.marshalling.MarshallerProvider;
import io.netty.handler.codec.marshalling.MarshallingDecoder;
import io.netty.handler.codec.marshalling.MarshallingEncoder;
import io.netty.handler.codec.marshalling.UnmarshallerProvider;
//Marshalling编解码器的工厂类
public final class MarshallingCodeCFactory
{
//创建JBoss Marshalling解码器
public static MarshallingDecoder buildMarshallingDecoder(){
final MarshallerFactory marshallerFactory=Marshalling