V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
qingfengxm
V2EX  ›  Java

netty 私有协议栈开发的坑

  •  
  •   qingfengxm · Sep 21, 2017 · 3545 views
    This topic created in 3149 days ago, the information mentioned may be changed or developed.

    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 直接就报错了,各位大神有懂的吗?

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1163 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 23:07 · PVG 07:07 · LAX 16:07 · JFK 19:07
    ♥ Do have faith in what you're doing.