本文整理了Java中org.jboss.netty.channel.Channels.pipelineFactory()
方法的一些代码示例,展示了Channels.pipelineFactory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Channels.pipelineFactory()
方法的具体详情如下:
包路径:org.jboss.netty.channel.Channels
类名称:Channels
方法名:pipelineFactory
[英]Creates a new ChannelPipelineFactory which creates a new ChannelPipeline which contains the same entries with the specified pipeline. Please note that only the names and the references of the ChannelHandlers will be copied; a new ChannelHandler instance will never be created.
[中]创建一个新的ChannelPipelineFactory,该工厂创建一个新的ChannelPipeline,其中包含与指定管道相同的条目。请注意,仅复制ChannelHandler的名称和引用;永远不会创建新的ChannelHandler实例。
代码示例来源:origin: io.netty/netty
/**
* Sets the default {@link ChannelPipeline} which is cloned when a new
* {@link Channel} is created. {@link Bootstrap} creates a new pipeline
* which has the same entries with the specified pipeline for a new channel.
* <p>
* Calling this method also sets the {@code pipelineFactory} property to an
* internal {@link ChannelPipelineFactory} implementation which returns
* a shallow copy of the specified pipeline.
* <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).
*/
public void setPipeline(ChannelPipeline pipeline) {
if (pipeline == null) {
throw new NullPointerException("pipeline");
}
this.pipeline = pipeline;
pipelineFactory = pipelineFactory(pipeline);
}
代码示例来源:origin: com.facebook.nifty/nifty-core
@Test
public void testNettyConfigBuilder()
{
NettyServerConfigBuilder configBuilder = new NettyServerConfigBuilder();
configBuilder.getServerSocketChannelConfig().setReceiveBufferSize(10000);
configBuilder.getServerSocketChannelConfig().setBacklog(1000);
configBuilder.getServerSocketChannelConfig().setReuseAddress(true);
ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory());
bootstrap.setOptions(configBuilder.getBootstrapOptions());
bootstrap.setPipelineFactory(Channels.pipelineFactory(Channels.pipeline()));
Channel serverChannel = bootstrap.bind(new InetSocketAddress(port));
Assert.assertEquals(((ServerSocketChannelConfig) serverChannel.getConfig()).getReceiveBufferSize(), 10000);
Assert.assertEquals(((ServerSocketChannelConfig) serverChannel.getConfig()).getBacklog(), 1000);
Assert.assertTrue(((ServerSocketChannelConfig) serverChannel.getConfig()).isReuseAddress());
}
}
代码示例来源:origin: k3po/k3po
try {
ServerBootstrap server = serverResolver.resolve();
server.setPipelineFactory(pipelineFactory(pipeline(closeOnExceptionHandler)));
} catch (RuntimeException e) {
LOGGER.warn("Exception caught while trying to stop server pipelies", e);
try {
ClientBootstrap client = clientResolver.resolve();
client.setPipelineFactory(pipelineFactory(pipeline(closeOnExceptionHandler)));
} catch (RuntimeException e) {
LOGGER.warn("Exception caught while trying to stop client pipelies", e);
内容来源于网络,如有侵权,请联系作者删除!