1、关于JBOSS的Marshalling的简介
JBoss Marshalling 是一个Java对象的序列化API包,修正了JDK自带的序列化包的很多问题,但又保持跟 java.io.Serializable 接口的兼容;同时增加了一些可调的参数和附加的特性,而这些参数和特性可通过工厂类进行配置。
2、关于JBoss的Marshalling的配置
2.1 服务端的配置
2.2 客户端的配置
2.3 直接发送和接收对象
3、关于JBoss的Marshalling的工厂类
- 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;
-
- import org.jboss.marshalling.MarshallerFactory;
- import org.jboss.marshalling.Marshalling;
- import org.jboss.marshalling.MarshallingConfiguration;
-
-
-
-
-
- public final class MarshallingCodeCFactory {
-
-
-
-
-
-
- public static MarshallingDecoder buildMarshallingDecoder() {
-
- final MarshallerFactory marshallerFactory = Marshalling
- .getProvidedMarshallerFactory("serial");
-
- final MarshallingConfiguration configuration = new MarshallingConfiguration();
- configuration.setVersion(5);
-
- UnmarshallerProvider provider = new DefaultUnmarshallerProvider(
- marshallerFactory, configuration);
-
- MarshallingDecoder decoder = new MarshallingDecoder(provider,
- 1024 * 1024 * 1);
- return decoder;
- }
-
-
-
-
-
-
- public static MarshallingEncoder buildMarshallingEncoder() {
- final MarshallerFactory marshallerFactory = Marshalling
- .getProvidedMarshallerFactory("serial");
- final MarshallingConfiguration configuration = new MarshallingConfiguration();
- configuration.setVersion(5);
- MarshallerProvider provider = new DefaultMarshallerProvider(
- marshallerFactory, configuration);
-
- MarshallingEncoder encoder = new MarshallingEncoder(provider);
- return encoder;
- }
- }
4、服务端的实现