Java Code Examples for org.jboss.netty.handler.codec.string.StringEncoder
The following examples show how to use
org.jboss.netty.handler.codec.string.StringEncoder. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: migration-tool Source File: NettyServer.java License: Apache License 2.0 | 6 votes |
public void start(int listenPort, final ExecutorService threadPool, final long timeout) throws Exception { if (!startFlag.compareAndSet(false, true)) { return; } bootstrap.setPipelineFactory(new ChannelPipelineFactory() { public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = new DefaultChannelPipeline(); pipeline.addLast("decoder", new StringDecoder()); pipeline.addLast("encoder", new StringEncoder()); pipeline.addLast("handler", new NettyServerHandler(threadPool, timeout)); return pipeline; } }); bootstrap.bind(new InetSocketAddress(listenPort)); log.warn("Server started,listen at: " + listenPort); }
Example 2
Source Project: kairos-carbon Source File: CarbonTextServer.java License: Apache License 2.0 | 6 votes |
@Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = Channels.pipeline(); // Add the text line codec combination first, FrameDecoder frameDecoder = new LineBasedFrameDecoder( m_maxSize, true, true); pipeline.addLast("framer", frameDecoder); pipeline.addLast("decoder", new WordSplitter()); pipeline.addLast("encoder", new StringEncoder()); // and then business logic. pipeline.addLast("handler", this); return pipeline; }
Example 3
Source Project: jlogstash-input-plugin Source File: NettySend.java License: Apache License 2.0 | 5 votes |
public void connect(){ bootstrap = new ClientBootstrap( new NioClientSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool())); bootstrap.setOption("tcpNoDelay", false); bootstrap.setOption("keepAlive", true); final NettyClientHandler handler = new NettyClientHandler(this, timer); bootstrap.setPipelineFactory(new ChannelPipelineFactory() { public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("handler", handler); pipeline.addLast("encoder", new StringEncoder()); return pipeline; } }); bootstrap.setOption("remoteAddress", new InetSocketAddress(host, port)); try { ChannelFuture future = bootstrap.connect().sync(); channel = future.getChannel(); } catch (Exception e) { logger.error(ExceptionUtil.getErrorMessage(e)); bootstrap.releaseExternalResources(); System.exit(-1);//第一次连接出现异常直接退出,不走重连 } }
Example 4
Source Project: migration-tool Source File: NettyClientPipelineFactory.java License: Apache License 2.0 | 5 votes |
@Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = new DefaultChannelPipeline(); pipeline.addLast("decoder", new StringDecoder()); pipeline.addLast("encoder", new StringEncoder()); pipeline.addLast("handler", handler); return pipeline; }
Example 5
Source Project: vmstats Source File: NettyTCPWriterPipelineFactory.java License: Apache License 2.0 | 5 votes |
public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = pipeline(); pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter())); pipeline.addLast("decoder", new StringDecoder()); pipeline.addLast("encoder", new StringEncoder()); pipeline.addLast("handler", new NettyTCPWriterHandler(this.bootstrap, this.channel, this.timer)); return pipeline; }
Example 6
Source Project: vmstats Source File: FakeCarbonPipelineFactory.java License: Apache License 2.0 | 5 votes |
public ChannelPipeline getPipeline() throws Exception { // this is pretty verbose from the netty examples ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter())); pipeline.addLast("decoder", new StringDecoder()); pipeline.addLast("encoder", new StringEncoder()); pipeline.addLast("handler", new FakeCarbonHandler(appConfig)); return pipeline; }
Example 7
Source Project: james-project Source File: ManageSieveServer.java License: Apache License 2.0 | 4 votes |
@Override protected ChannelPipelineFactory createPipelineFactory(final ChannelGroup group) { return new ChannelPipelineFactory() { private final ChannelGroupHandler groupHandler = new ChannelGroupHandler(group); @Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = pipeline(); Encryption secure = getEncryption(); if (secure != null && !secure.isStartTLS()) { // We need to set clientMode to false. // See https://issues.apache.org/jira/browse/JAMES-1025 SSLEngine engine = secure.getContext().createSSLEngine(); engine.setUseClientMode(false); pipeline.addFirst(SSL_HANDLER, new SslHandler(engine)); } pipeline.addLast(GROUP_HANDLER, groupHandler); pipeline.addLast(CONNECTION_LIMIT_HANDLER, new ConnectionLimitUpstreamHandler(ManageSieveServer.this.connectionLimit)); pipeline.addLast(CONNECTION_LIMIT_PER_IP_HANDLER, new ConnectionPerIpLimitUpstreamHandler(ManageSieveServer.this.connPerIP)); // Add the text line decoder which limit the max line length, // don't strip the delimiter and use CRLF as delimiter // Use a SwitchableDelimiterBasedFrameDecoder, see JAMES-1436 pipeline.addLast(FRAMER, getFrameHandlerFactory().create(pipeline)); pipeline.addLast(CONNECTION_COUNT_HANDLER, getConnectionCountHandler()); pipeline.addLast(CHUNK_WRITE_HANDLER, new ChunkedWriteHandler()); ExecutionHandler ehandler = getExecutionHandler(); if (ehandler != null) { pipeline.addLast(EXECUTION_HANDLER, ehandler); } pipeline.addLast("stringDecoder", new StringDecoder(CharsetUtil.UTF_8)); pipeline.addLast(CORE_HANDLER, createCoreHandler()); pipeline.addLast("stringEncoder", new StringEncoder(CharsetUtil.UTF_8)); return pipeline; } }; }