java类org.jboss.netty.channel.ChannelHandler的实例源码

CodecFactory.java 文件源码 项目:BJAF3.x 阅读 40 收藏 0 点赞 0 评论 0
public static ChannelHandler createDecoder() {
    int maxObjectSize = AppProperties.getAsInt("rpc_common_maxObjectSize",
            1024 * 1024);
    String f = AppProperties.get("rpc_common_codec", "java");
    if (f.equalsIgnoreCase("java")) {
        return new ObjectDecoder(maxObjectSize,
                ClassResolvers.softCachingConcurrentResolver(null));
    } else if (f.equalsIgnoreCase("jbossSerialization")) {
        return new JBossSerializationDecoder(maxObjectSize);
    } else if (f.equalsIgnoreCase("json")) {
        throw new AppRuntimeException("not support " + f + " yet!");
    } else if (f.equalsIgnoreCase("hessian")) {
        return new HessianDecoder(maxObjectSize);
    } else {
        throw new AppRuntimeException("not support " + f + " yet!");
    }
}
NettyHttpGetWithInvalidMessageTest.java 文件源码 项目:Camel 阅读 33 收藏 0 点赞 0 评论 0
@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry registry = super.createRegistry();

    // setup the String encoder and decoder 

    StringDecoder stringDecoder = new StringDecoder();
    registry.bind("string-decoder", stringDecoder);

    StringEncoder stringEncoder = new StringEncoder();
    registry.bind("string-encoder", stringEncoder);

    List<ChannelHandler> decoders = new ArrayList<ChannelHandler>();
    decoders.add(stringDecoder);

    List<ChannelHandler> encoders = new ArrayList<ChannelHandler>();
    encoders.add(stringEncoder);

    registry.bind("encoders", encoders);
    registry.bind("decoders", decoders);

    return registry;
}
MasterServer.java 文件源码 项目:dataworks-zeus 阅读 29 收藏 0 点赞 0 评论 0
public MasterServer(final ChannelHandler handler){
    NioServerSocketChannelFactory channelFactory=
        new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
    bootstrap=new ServerBootstrap(channelFactory);
    pipelineFactory=new ChannelPipelineFactory(){
        private final ProtobufVarint32LengthFieldPrepender frameEncoder = new ProtobufVarint32LengthFieldPrepender();
        private final ProtobufEncoder protobufEncoder = new ProtobufEncoder();
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline p = pipeline();
            p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
            p.addLast("protobufDecoder",new ProtobufDecoder(Protocol.SocketMessage.getDefaultInstance()));
            p.addLast("frameEncoder", frameEncoder);
            p.addLast("protobufEncoder", protobufEncoder);
            p.addLast("handler", handler);
            return p;
        }

    };
    try {
        bootstrap.setPipeline(pipelineFactory.getPipeline());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
MasterServer.java 文件源码 项目:dataworks-zeus 阅读 40 收藏 0 点赞 0 评论 0
public MasterServer(final ChannelHandler handler){
    NioServerSocketChannelFactory channelFactory=
        new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
    bootstrap=new ServerBootstrap(channelFactory);
    pipelineFactory=new ChannelPipelineFactory(){
        private final ProtobufVarint32LengthFieldPrepender frameEncoder = new ProtobufVarint32LengthFieldPrepender();
        private final ProtobufEncoder protobufEncoder = new ProtobufEncoder();
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline p = pipeline();
            p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
            p.addLast("protobufDecoder",new ProtobufDecoder(Protocol.SocketMessage.getDefaultInstance()));
            p.addLast("frameEncoder", frameEncoder);
            p.addLast("protobufEncoder", protobufEncoder);
            p.addLast("handler", handler);
            return p;
        }

    };
    try {
        bootstrap.setPipeline(pipelineFactory.getPipeline());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
NettyClient.java 文件源码 项目:my-dev 阅读 33 收藏 0 点赞 0 评论 0
private static ClientBootstrap prepareBootstrap(Logger logger, final ChannelPipeline pipeline,
        ChannelHandler handler, SslHandler sslHandler, int connectTimeoutMillis) {
    ClientBootstrap bootstrap = new ClientBootstrap(nioClientSocketChannelFactory);
    bootstrap.setOption("tcpNoDelay", true);
    bootstrap.setOption("reuseAddress", true);
    bootstrap.setOption("connectTimeoutMillis", connectTimeoutMillis);
    bootstrap.setOption("writeBufferHighWaterMark", 10 * 1024 * 1024);

    if (sslHandler != null) {
        pipeline.addFirst("ssl", sslHandler);
    }
    if (handler != null) {
        pipeline.addLast("handler", handler);
    }

    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {

        @Override
        public ChannelPipeline getPipeline() throws Exception {
            return pipeline;
        }
    });
    return bootstrap;
}
MasterServer.java 文件源码 项目:zeus3 阅读 35 收藏 0 点赞 0 评论 0
public MasterServer(final ChannelHandler handler){
    NioServerSocketChannelFactory channelFactory=
        new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
    bootstrap=new ServerBootstrap(channelFactory);
    pipelineFactory=new ChannelPipelineFactory(){
        private final ProtobufVarint32LengthFieldPrepender frameEncoder = new ProtobufVarint32LengthFieldPrepender();
        private final ProtobufEncoder protobufEncoder = new ProtobufEncoder();
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline p = pipeline();
            p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
            p.addLast("protobufDecoder",new ProtobufDecoder(Protocol.SocketMessage.getDefaultInstance()));
            p.addLast("frameEncoder", frameEncoder);
            p.addLast("protobufEncoder", protobufEncoder);
            p.addLast("handler", handler);
            return p;
        }

    };
    try {
        bootstrap.setPipeline(pipelineFactory.getPipeline());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
ControllerConnector.java 文件源码 项目:FlowSpaceFirewall 阅读 32 收藏 0 点赞 0 评论 0
/**
 * creates a new pipeline for interacting with the
 * controller.  This is where the controllerHandler and
 * the timeouthandler come into play
 * @return the pipeline (ChannelPipeline) for a new Socket.
 */
private ChannelPipeline getPipeline(){
    ChannelPipeline pipe = Channels.pipeline();

    ChannelHandler idleHandler = new IdleStateHandler(timer, 20, 25, 0);
    ChannelHandler readTimeoutHandler = new ReadTimeoutHandler(timer, 30);
    OFControllerChannelHandler controllerHandler = new OFControllerChannelHandler();

       pipe.addLast("ofmessagedecoder", new OFMessageDecoder());
       pipe.addLast("ofmessageencoder", new OFMessageEncoder());
       pipe.addLast("idle", idleHandler);
       pipe.addLast("timeout", readTimeoutHandler);
       pipe.addLast("handshaketimeout",
                    new ControllerHandshakeTimeoutHandler(controllerHandler, timer, 15));
       pipe.addLast("handler", controllerHandler);
       return pipe;
}
IsdnHandlerFactory.java 文件源码 项目:netty-isdn-transport 阅读 30 收藏 0 点赞 0 评论 0
public static ChannelHandler getIsdnClientStateMachineHandler(IsdnChannel channel, String handlerName) {

        StateMachine sm = StateMachineFactory.getInstance(Transition.class).create(IsdnConnectionHandler.PLCI_IDLE,
                new IsdnConnectionHandler());

        StateContextLookup stateContextLookup = new ChannelHandlerContextLookup(new DefaultStateContextFactory(),
                channel, handlerName);

        StateMachineProxyBuilder proxyBuilder = new StateMachineProxyBuilder();
        proxyBuilder.setName("IsdnClientChannelStateMachine");
        proxyBuilder.setStateContextLookup(stateContextLookup);
        // proxyBuilder.setEventArgumentsInterceptor(new
        // NettyEventInterceptor());
        proxyBuilder.setEventFactory(new NettyEventFactory());

        IStateMachineChannelHandler engine = proxyBuilder.create(IStateMachineChannelHandler.class, sm);
        return new ChannelAllCoverageWrapper(new DefaultStateMachineChannelHandler(engine));

    }
IsdnHandlerFactory.java 文件源码 项目:netty-isdn-transport 阅读 22 收藏 0 点赞 0 评论 0
public static ChannelHandler getAcceptedChannelStateMachineHandler(IsdnChannel channel, String handlerName) {

        StateMachine sm = StateMachineFactory.getInstance(Transition.class).create(
                IsdnConnectionHandler.P4_WF_CONNECT_ACTIVE_IND, new IsdnConnectionHandler());

        StateContextLookup stateContextLookup = new ChannelHandlerContextLookup(new DefaultStateContextFactory(),
                channel, handlerName);

        StateMachineProxyBuilder proxyBuilder = new StateMachineProxyBuilder();
        proxyBuilder.setName("IsdnAcceptedChannelStateMachine");
        proxyBuilder.setStateContextLookup(stateContextLookup);
        // proxyBuilder.setEventArgumentsInterceptor(new
        // NettyEventInterceptor());
        proxyBuilder.setEventFactory(new NettyEventFactory());

        IStateMachineChannelHandler engine = proxyBuilder.create(IStateMachineChannelHandler.class, sm);
        return new ChannelAllCoverageWrapper(new DefaultStateMachineChannelHandler(engine));

    }
FrameDecoder.java 文件源码 项目:android-netty 阅读 33 收藏 0 点赞 0 评论 0
/**
 * Replace this {@link FrameDecoder} in the {@link ChannelPipeline} with the
 * given {@link ChannelHandler}. All remaining bytes in the
 * {@link ChannelBuffer} will get send to the new {@link ChannelHandler}
 * that was used as replacement
 * 
 */
public void replace(String handlerName, ChannelHandler handler) {
    if (ctx == null) {
        throw new IllegalStateException("Replace cann only be called once the FrameDecoder is added to the ChannelPipeline");
    }
    ChannelPipeline pipeline = ctx.getPipeline();
    pipeline.addAfter(ctx.getName(), handlerName, handler);

    try {
        if (cumulation != null) {
            Channels.fireMessageReceived(ctx, cumulation.readBytes(actualReadableBytes()));
        }
    } finally {
        pipeline.remove(this);
    }
}
Bootstrap.java 文件源码 项目:android-netty 阅读 31 收藏 0 点赞 0 评论 0
/**
 * Dependency injection friendly convenience method for
 * {@link #setPipeline(ChannelPipeline)} which sets the default pipeline of
 * this bootstrap from an ordered map.
 * <p>
 * Please note that this method is a convenience method that works only
 * when <b>1)</b> you create only one channel from this bootstrap (e.g.
 * one-time client-side or connectionless channel) or <b>2)</b> all handlers
 * in the pipeline is stateless.  You have to use
 * {@link #setPipelineFactory(ChannelPipelineFactory)} if <b>1)</b> your
 * pipeline contains a stateful {@link ChannelHandler} and <b>2)</b> one or
 * more channels are going to be created by this bootstrap (e.g. server-side
 * channels).
 *
 * @throws IllegalArgumentException
 *         if the specified map is not an ordered map
 */
public void setPipelineAsMap(Map<String, ChannelHandler> pipelineMap) {
    if (pipelineMap == null) {
        throw new NullPointerException("pipelineMap");
    }

    if (!isOrderedMap(pipelineMap)) {
        throw new IllegalArgumentException(
                "pipelineMap is not an ordered map. " +
                "Please use " +
                LinkedHashMap.class.getName() + '.');
    }

    ChannelPipeline pipeline = pipeline();
    for (Map.Entry<String, ChannelHandler> e: pipelineMap.entrySet()) {
        pipeline.addLast(e.getKey(), e.getValue());
    }

    setPipeline(pipeline);
}
PNPClientPipelineFactory.java 文件源码 项目:proactive-component-monitoring 阅读 31 收藏 0 点赞 0 评论 0
public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline p = Channels.pipeline();

    if (extraHandlers != null) {
        for (final ChannelHandler handler : this.extraHandlers.getClientHandlers()) {
            p.addLast("" + handler.hashCode(), handler);
        }
    }

    // Do not use FixedLengthFrameDecoder provided by netty to avoid
    // copy and an extra handler to parse the messages
    //        p.addLast("pnpDecoder", new PNPClientFrameDecoder());
    p.addLast("pnpDecoder", new PNPClientFrameDecoder());

    p.addLast("frameEncoder", new LengthFieldPrepender(4));
    p.addLast("pnpEncoder", new PNPEncoder());

    long idle_timeout = PNPConfig.PA_PNP_IDLE_TIMEOUT.getValue();
    if (idle_timeout != 0) {
        p.addLast("timer", new IdleStateHandler(timer, 0, idle_timeout, 0, TimeUnit.MILLISECONDS));
    }

    p.addLast(PNPClientHandler.NAME, new PNPClientHandler());
    return p;
}
PNPServerPipelineFactory.java 文件源码 项目:proactive-component-monitoring 阅读 19 收藏 0 点赞 0 评论 0
public ChannelPipeline getPipeline() throws Exception {
    PNPServerHandler pnpServerHandler = new PNPServerHandler(this.executor);
    ChannelPipeline p = Channels.pipeline();

    if (extraHandlers != null) {
        for (final ChannelHandler handler : extraHandlers.getServertHandlers()) {
            p.addLast("" + handler.hashCode(), handler);
        }
    }

    p.addLast("pnpDecoder", new PNPServerFrameDecoder(pnpServerHandler, timer));
    p.addLast("frameEncoder", new LengthFieldPrepender(4));
    p.addLast("pnpEncoder", new PNPEncoder());
    p.addLast(PNPServerHandler.NAME, pnpServerHandler);
    return p;
}
NettyCodecAdapter.java 文件源码 项目:EatDubbo 阅读 28 收藏 0 点赞 0 评论 0
public NettyCodecAdapter(Codec2 codec, URL url, com.alibaba.dubbo.remoting.ChannelHandler handler) {
    this.codec = codec;
    this.url = url;
    this.handler = handler;
    int b = url.getPositiveParameter(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE);
    this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE;
}
NettyCodecAdapter.java 文件源码 项目:dubbo2 阅读 31 收藏 0 点赞 0 评论 0
public NettyCodecAdapter(Codec2 codec, URL url, com.alibaba.dubbo.remoting.ChannelHandler handler) {
    this.codec = codec;
    this.url = url;
    this.handler = handler;
    int b = url.getPositiveParameter(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE);
    this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE;
}
BasePipelineFactory.java 文件源码 项目:traccar-service 阅读 31 收藏 0 点赞 0 评论 0
private void addDynamicHandlers(ChannelPipeline pipeline) {
    if (Context.getConfig().hasKey("extra.handlers")) {
        String[] handlers = Context.getConfig().getString("extra.handlers").split(",");
        for (int i = 0; i < handlers.length; i++) {
            try {
                pipeline.addLast("extraHandler." + i, (ChannelHandler) Class.forName(handlers[i]).newInstance());
            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException error) {
                Log.warning(error);
            }
        }
    }
}
NettyCodecAdapter.java 文件源码 项目:dubbox-hystrix 阅读 34 收藏 0 点赞 0 评论 0
public NettyCodecAdapter(Codec2 codec, URL url, com.alibaba.dubbo.remoting.ChannelHandler handler) {
    this.codec = codec;
    this.url = url;
    this.handler = handler;
    int b = url.getPositiveParameter(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE);
    this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE;
}
NettyCodecAdapter.java 文件源码 项目:dubbocloud 阅读 32 收藏 0 点赞 0 评论 0
public NettyCodecAdapter(Codec2 codec, URL url, com.alibaba.dubbo.remoting.ChannelHandler handler) {
    this.codec = codec;
    this.url = url;
    this.handler = handler;
    int b = url.getPositiveParameter(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE);
    this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE;
}
NettyCodecAdapter.java 文件源码 项目:dubbos 阅读 29 收藏 0 点赞 0 评论 0
public NettyCodecAdapter(Codec2 codec, URL url, com.alibaba.dubbo.remoting.ChannelHandler handler) {
    this.codec = codec;
    this.url = url;
    this.handler = handler;
    int b = url.getPositiveParameter(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE);
    this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE;
}
BeatsTransport.java 文件源码 项目:graylog-plugin-beats 阅读 25 收藏 0 点赞 0 评论 0
@Override
protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getFinalChannelHandlers(MessageInput input) {
    final LinkedHashMap<String, Callable<? extends ChannelHandler>> finalChannelHandlers = super.getFinalChannelHandlers(input);
    final LinkedHashMap<String, Callable<? extends ChannelHandler>> handlers = new LinkedHashMap<>();
    handlers.put("beats", BeatsFrameDecoder::new);
    handlers.putAll(finalChannelHandlers);

    return handlers;
}
BeatsTransportTest.java 文件源码 项目:graylog-plugin-beats 阅读 47 收藏 0 点赞 0 评论 0
@Test
public void getFinalChannelHandlers() throws Exception {
    final BeatsTransport transport = new BeatsTransport(
            new Configuration(null),
            new ThroughputCounter(new HashedWheelTimer()),
            new LocalMetricRegistry(),
            Executors.newSingleThreadExecutor(),
            new ConnectionCounter()
    );

    final MessageInput input = mock(MessageInput.class);
    final LinkedHashMap<String, Callable<? extends ChannelHandler>> channelHandlers = transport.getFinalChannelHandlers(input);
    assertThat(channelHandlers).containsKey("beats");
}
MetricsDI.java 文件源码 项目:bigstreams 阅读 33 收藏 0 点赞 0 评论 0
@Bean
public ChannelHandler metricChannelFactory() {

    return new MetricChannel(
            (CounterMetric) beanFactory
                    .getBean("connectionsReceivedMetric"),
            (CounterMetric) beanFactory
                    .getBean("connectionsProcessedMetric"),
            (CounterMetric) beanFactory.getBean("kilobytesWrttenMetric"),
            (CounterMetric) beanFactory.getBean("kilobytesReceivedMetric"),
            (CounterMetric) beanFactory.getBean("errorsMetric"));

}
CollectorServerImpl.java 文件源码 项目:bigstreams 阅读 25 收藏 0 点赞 0 评论 0
public CollectorServerImpl(int port, ChannelHandler channelHandler,
        Configuration conf, ChannelHandler metricsHandler,
        IpFilterHandler ipFilterHandler) {
    super();
    this.port = port;
    this.channelHandler = channelHandler;
    this.conf = conf;
    this.metricsHandler = metricsHandler;
    this.ipFilterHandler = ipFilterHandler;
}
CoordinationServerImpl.java 文件源码 项目:bigstreams 阅读 27 收藏 0 点赞 0 评论 0
public CoordinationServerImpl(int lockPort, int releaseLockPort,
        ChannelHandler lockHandler, ChannelHandler unlockHandler,
        ChannelHandler metricHandler) {
    super();
    this.lockPort = lockPort;
    this.releaseLockPort = releaseLockPort;
    this.lockHandler = lockHandler;
    this.unlockHandler = unlockHandler;
    this.metricHandler = metricHandler;
}
NettyCodecAdapter.java 文件源码 项目:dubbo-comments 阅读 36 收藏 0 点赞 0 评论 0
public NettyCodecAdapter(Codec2 codec, URL url, com.alibaba.dubbo.remoting.ChannelHandler handler) {
    this.codec = codec;
    this.url = url;
    this.handler = handler;
    int b = url.getPositiveParameter(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE);
    this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE;
}
NettyCodecAdapter.java 文件源码 项目:dubbox 阅读 40 收藏 0 点赞 0 评论 0
public NettyCodecAdapter(Codec2 codec, URL url, com.alibaba.dubbo.remoting.ChannelHandler handler) {
    this.codec = codec;
    this.url = url;
    this.handler = handler;
    int b = url.getPositiveParameter(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE);
    this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE;
}
NettyCodecAdapter.java 文件源码 项目:dubbo 阅读 39 收藏 0 点赞 0 评论 0
public NettyCodecAdapter(Codec2 codec, URL url, com.alibaba.dubbo.remoting.ChannelHandler handler) {
    this.codec = codec;
    this.url = url;
    this.handler = handler;
    int b = url.getPositiveParameter(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE);
    this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE;
}
NettyCodecAdapter.java 文件源码 项目:dubbo3 阅读 31 收藏 0 点赞 0 评论 0
public NettyCodecAdapter(Codec2 codec, URL url, com.alibaba.dubbo.remoting.ChannelHandler handler) {
    this.codec = codec;
    this.url = url;
    this.handler = handler;
    int b = url.getPositiveParameter(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE);
    this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE;
}
NettyServer.java 文件源码 项目:Netty-Resteasy-Spring 阅读 22 收藏 0 点赞 0 评论 0
public void start() {
    ResteasyDeployment dp = new ResteasyDeployment();
    Collection<Object> providers = ac.getBeansWithAnnotation(Provider.class).values();
    Collection<Object> controllers = ac.getBeansWithAnnotation(Controller.class).values();
    Assert.notEmpty(controllers);
    // extract providers
    if (providers != null) {
        dp.getProviders().addAll(providers);
    }
    // extract only controller annotated beans
    dp.getResources().addAll(controllers);
    Map<String, Object> channelOptions = new HashMap<String, Object>();
    channelOptions.put("reuseAddress", true);
    List<ChannelHandler> channelHandlerList = new ArrayList<ChannelHandler>();
    channelHandlerList.add(channelHandler);
    channelHandlerList.add(idleStateHandler);
    channelHandlerList.add(healthCheckHandler);
    netty = new NettyJaxrsServer();
    netty.setChannelOptions(channelOptions);
    netty.setDeployment(dp);
    netty.setPort(port);
    netty.setRootResourcePath("/resteasy");
    netty.setIoWorkerCount(ioWorkerCount);
    netty.setExecutorThreadCount(executorThreadCount);
    netty.setMaxRequestSize(maxRequestSize);
    netty.setSSLContext(sslContext);
    netty.setKeepAlive(true);
    netty.setChannelHandlers(channelHandlerList);
    netty.setSecurityDomain(null);
    netty.start();
}
CodecFactory.java 文件源码 项目:BJAF3.x 阅读 35 收藏 0 点赞 0 评论 0
public static ChannelHandler createEncoder() {
    String f = AppProperties.get("rpc_common_codec", "java");
    if (f.equalsIgnoreCase("java")) {
        return new ObjectEncoder();
    } else if (f.equalsIgnoreCase("jbossSerialization")) {
        return new JBossSerializationEncoder();
    } else if (f.equalsIgnoreCase("json")) {
        throw new AppRuntimeException("not support " + f + " yet!");
    } else if (f.equalsIgnoreCase("hessian")) {
        return new HessianEncoder();
    } else {
        throw new AppRuntimeException("not support " + f + " yet!");
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号