Search in sources :

Example 1 with StringEncoder

use of org.jboss.netty.handler.codec.string.StringEncoder in project camel by apache.

the class NettySingleCodecTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry registry = super.createRegistry();
    StringEncoder stringEncoder = new StringEncoder();
    StringDecoder stringDecoder = new StringDecoder();
    registry.bind("encoder", stringEncoder);
    registry.bind("decoder", stringDecoder);
    return registry;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) StringEncoder(org.jboss.netty.handler.codec.string.StringEncoder) StringDecoder(org.jboss.netty.handler.codec.string.StringDecoder)

Example 2 with StringEncoder

use of org.jboss.netty.handler.codec.string.StringEncoder in project camel by apache.

the class MultipleCodecsTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry registry = super.createRegistry();
    // START SNIPPET: registry-beans
    ChannelHandlerFactory lengthDecoder = ChannelHandlerFactories.newLengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4);
    StringDecoder stringDecoder = new StringDecoder();
    registry.bind("length-decoder", lengthDecoder);
    registry.bind("string-decoder", stringDecoder);
    LengthFieldPrepender lengthEncoder = new LengthFieldPrepender(4);
    StringEncoder stringEncoder = new StringEncoder();
    registry.bind("length-encoder", lengthEncoder);
    registry.bind("string-encoder", stringEncoder);
    List<ChannelHandler> decoders = new ArrayList<ChannelHandler>();
    decoders.add(lengthDecoder);
    decoders.add(stringDecoder);
    List<ChannelHandler> encoders = new ArrayList<ChannelHandler>();
    encoders.add(lengthEncoder);
    encoders.add(stringEncoder);
    registry.bind("encoders", encoders);
    registry.bind("decoders", decoders);
    // END SNIPPET: registry-beans
    return registry;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) StringEncoder(org.jboss.netty.handler.codec.string.StringEncoder) ArrayList(java.util.ArrayList) StringDecoder(org.jboss.netty.handler.codec.string.StringDecoder) ChannelHandler(org.jboss.netty.channel.ChannelHandler) LengthFieldPrepender(org.jboss.netty.handler.codec.frame.LengthFieldPrepender)

Example 3 with StringEncoder

use of org.jboss.netty.handler.codec.string.StringEncoder in project bigbluebutton by bigbluebutton.

the class InboundPipelineFactory method getPipeline.

public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline pipeline = Channels.pipeline();
    pipeline.addLast("encoder", new StringEncoder());
    pipeline.addLast("decoder", new EslFrameDecoder(8192));
    // Add an executor to ensure separate thread for each upstream message from here
    pipeline.addLast("executor", new ExecutionHandler(new OrderedMemoryAwareThreadPoolExecutor(16, 1048576, 1048576)));
    // now the inbound client logic
    pipeline.addLast("clientHandler", handler);
    return pipeline;
}
Also used : StringEncoder(org.jboss.netty.handler.codec.string.StringEncoder) EslFrameDecoder(org.freeswitch.esl.client.transport.message.EslFrameDecoder) ExecutionHandler(org.freeswitch.esl.client.internal.debug.ExecutionHandler) OrderedMemoryAwareThreadPoolExecutor(org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline)

Example 4 with StringEncoder

use of org.jboss.netty.handler.codec.string.StringEncoder in project opennms by OpenNMS.

the class AsyncMultilineDetectorNettyImpl method appendToPipeline.

@Override
protected void appendToPipeline(ChannelPipeline retval) {
    // Upstream handlers
    retval.addLast("frameDecoder", new DelimiterBasedFrameDecoder(1024, Delimiters.lineDelimiter()));
    retval.addLast("stringDecoder", new StringDecoder(CharsetUtil.UTF_8));
    retval.addLast("multilineDecoder", new MultilineOrientedResponseDecoder());
    // Downstream handlers
    retval.addLast("stringEncoder", new StringEncoder(CharsetUtil.UTF_8));
    retval.addLast("lineEncoder", new LineOrientedRequestEncoder());
}
Also used : StringEncoder(org.jboss.netty.handler.codec.string.StringEncoder) MultilineOrientedResponseDecoder(org.opennms.netmgt.provision.detector.simple.support.MultilineOrientedResponseDecoder) DelimiterBasedFrameDecoder(org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder) StringDecoder(org.jboss.netty.handler.codec.string.StringDecoder) LineOrientedRequestEncoder(org.opennms.netmgt.provision.detector.simple.support.LineOrientedRequestEncoder)

Example 5 with StringEncoder

use of org.jboss.netty.handler.codec.string.StringEncoder in project yyl_example by Relucent.

the class NettyClient method main.

public static void main(String[] args) {
    ClientBootstrap bootstrap = new ClientBootstrap(new //
    NioClientSocketChannelFactory(//
    Executors.newCachedThreadPool(), //
    Executors.newCachedThreadPool()));
    // Set up the default event pipeline.
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {

        @Override
        public ChannelPipeline getPipeline() throws Exception {
            return Channels.pipeline(new StringDecoder(), new StringEncoder(), new ClientHandler());
        }
    });
    // Start the connection attempt.
    ChannelFuture future = bootstrap.connect(new InetSocketAddress("localhost", 8000));
    // Wait until the connection is closed or the connection attempt fails.
    future.getChannel().getCloseFuture().awaitUninterruptibly();
    // Shut down thread pools to exit.
    bootstrap.releaseExternalResources();
}
Also used : StringEncoder(org.jboss.netty.handler.codec.string.StringEncoder) ChannelFuture(org.jboss.netty.channel.ChannelFuture) ClientBootstrap(org.jboss.netty.bootstrap.ClientBootstrap) InetSocketAddress(java.net.InetSocketAddress) StringDecoder(org.jboss.netty.handler.codec.string.StringDecoder) ChannelPipelineFactory(org.jboss.netty.channel.ChannelPipelineFactory) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline)

Aggregations

StringEncoder (org.jboss.netty.handler.codec.string.StringEncoder)9 StringDecoder (org.jboss.netty.handler.codec.string.StringDecoder)7 JndiRegistry (org.apache.camel.impl.JndiRegistry)3 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)3 InetSocketAddress (java.net.InetSocketAddress)2 ArrayList (java.util.ArrayList)2 ExecutionHandler (org.freeswitch.esl.client.internal.debug.ExecutionHandler)2 EslFrameDecoder (org.freeswitch.esl.client.transport.message.EslFrameDecoder)2 ChannelHandler (org.jboss.netty.channel.ChannelHandler)2 DelimiterBasedFrameDecoder (org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder)2 OrderedMemoryAwareThreadPoolExecutor (org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor)2 LineOrientedRequestEncoder (org.opennms.netmgt.provision.detector.simple.support.LineOrientedRequestEncoder)2 ClientBootstrap (org.jboss.netty.bootstrap.ClientBootstrap)1 ServerBootstrap (org.jboss.netty.bootstrap.ServerBootstrap)1 ChannelFuture (org.jboss.netty.channel.ChannelFuture)1 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)1 LengthFieldPrepender (org.jboss.netty.handler.codec.frame.LengthFieldPrepender)1 LineOrientedResponseDecoder (org.opennms.netmgt.provision.detector.simple.support.LineOrientedResponseDecoder)1 MultilineOrientedResponseDecoder (org.opennms.netmgt.provision.detector.simple.support.MultilineOrientedResponseDecoder)1