Search in sources :

Example 6 with StringDecoder

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

the class NettyUdpConnectionlessSendTest method createNettyUdpReceiver.

public void createNettyUdpReceiver() {
    bootstrap = new ConnectionlessBootstrap(new NioDatagramChannelFactory());
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {

        @Override
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline channelPipeline = Channels.pipeline();
            channelPipeline.addLast("StringDecoder", new StringDecoder(CharsetUtil.UTF_8));
            channelPipeline.addLast("ContentHandler", new ContentHandler());
            return channelPipeline;
        }
    });
}
Also used : NioDatagramChannelFactory(org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory) StringDecoder(org.jboss.netty.handler.codec.string.StringDecoder) ChannelPipelineFactory(org.jboss.netty.channel.ChannelPipelineFactory) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) ConnectionlessBootstrap(org.jboss.netty.bootstrap.ConnectionlessBootstrap)

Example 7 with StringDecoder

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

the class NettyHttpGetWithInvalidMessageTest method createRegistry.

@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;
}
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)

Example 8 with StringDecoder

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

the class AsyncLineOrientedDetectorNettyImpl 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("lineDecoder", new LineOrientedResponseDecoder());
    // 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) 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) LineOrientedResponseDecoder(org.opennms.netmgt.provision.detector.simple.support.LineOrientedResponseDecoder)

Example 9 with StringDecoder

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

the class NettyServer method main.

public static void main(String[] args) {
    ServerBootstrap bootstrap = new //
    ServerBootstrap(new //
    NioServerSocketChannelFactory(// boss
    Executors.newCachedThreadPool(), // worker
    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 ServerHandler());
        }
    });
    // Bind and start to accept incoming connections.
    Channel bind = bootstrap.bind(new InetSocketAddress(8000));
    System.out.println("Server started, listening port: " + bind.getLocalAddress() + ", Waiting for client register...");
}
Also used : StringEncoder(org.jboss.netty.handler.codec.string.StringEncoder) InetSocketAddress(java.net.InetSocketAddress) StringDecoder(org.jboss.netty.handler.codec.string.StringDecoder) ServerBootstrap(org.jboss.netty.bootstrap.ServerBootstrap)

Aggregations

StringDecoder (org.jboss.netty.handler.codec.string.StringDecoder)9 StringEncoder (org.jboss.netty.handler.codec.string.StringEncoder)7 JndiRegistry (org.apache.camel.impl.JndiRegistry)3 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)3 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)3 InetSocketAddress (java.net.InetSocketAddress)2 ArrayList (java.util.ArrayList)2 ConnectionlessBootstrap (org.jboss.netty.bootstrap.ConnectionlessBootstrap)2 ChannelHandler (org.jboss.netty.channel.ChannelHandler)2 NioDatagramChannelFactory (org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory)2 DelimiterBasedFrameDecoder (org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder)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 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