V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
qingfengxm
V2EX  ›  Java

netty 私有协议栈开发的坑

  •  
  •   qingfengxm · 2017-09-21 10:29:36 +08:00 · 3036 次点击
    这是一个创建于 2650 天前的主题,其中的信息可能已经有所发展或是发生改变。

    package com.netty.protocol;

    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.UnmarshallerProvider; import org.jboss.marshalling.MarshallerFactory; import org.jboss.marshalling.Marshalling; import org.jboss.marshalling.MarshallingConfiguration;

    public class MarshallingCodeCFactory { public static NettyMarshallingDecoder buildMarshallingDecoder(){ final MarshallerFactory marshallerFactory = Marshalling.getProvidedMarshallerFactory("serial"); final MarshallingConfiguration configuration = new MarshallingConfiguration(); configuration.setVersion(5); UnmarshallerProvider provider = new DefaultUnmarshallerProvider(marshallerFactory, configuration); int maxSize = 1024 << 2; NettyMarshallingDecoder decoder = new NettyMarshallingDecoder(provider, maxSize); return decoder; }

    public static NettyMarshallingEncoder buildMarshallingEncoder(){
    	final MarshallerFactory marshallerFactory = Marshalling.getProvidedMarshallerFactory("serial");
    	final MarshallingConfiguration configuration = new MarshallingConfiguration();
    	configuration.setVersion(5);
    	MarshallerProvider provider = new DefaultMarshallerProvider(marshallerFactory, configuration);
    	NettyMarshallingEncoder encoder = new NettyMarshallingEncoder(provider);
    	return encoder;
    }
    

    }

    marshallerFactory 获取到为 null,是什么情况?用下边构造 encoder decoder 直接就报错了,各位大神有懂的吗?

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5849 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 01:42 · PVG 09:42 · LAX 17:42 · JFK 20:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.