Example usage for io.netty.channel.local LocalChannel remoteAddress

List of usage examples for io.netty.channel.local LocalChannel remoteAddress

Introduction

In this page you can find the example usage for io.netty.channel.local LocalChannel remoteAddress.

Prototype

LocalAddress remoteAddress

To view the source code for io.netty.channel.local LocalChannel remoteAddress.

Click Source Link

Usage

From source file:org.opendaylight.usc.plugin.UscPlugin.java

License:Open Source License

protected UscPlugin(LocalAddress localAddr) {
    LOG.debug("UscPlugin " + this + "started");
    localServerAddr = localAddr;/*w  w  w. j  a  v a2  s  . c o  m*/

    final ServerBootstrap localServerBootstrap = new ServerBootstrap();
    localServerBootstrap.group(localGroup);
    localServerBootstrap.channel(LocalServerChannel.class);
    localServerBootstrap.childHandler(new ChannelInitializer<LocalChannel>() {
        @Override
        public void initChannel(final LocalChannel serverChannel) throws Exception {
            ChannelPipeline p = serverChannel.pipeline();
            p.addLast(new LoggingHandler("localServerBootstrp Handler 4", LogLevel.TRACE));

            // call this first so that the attribute will be visible
            // to the outside once the localAddress is set
            serverChannel.attr(SESSION).setIfAbsent(SettableFuture.<UscSessionImpl>create());

            // register the child channel by address for lookup
            // outside
            LocalAddress localAddress = serverChannel.remoteAddress();
            serverChannels.putIfAbsent(localAddress, SettableFuture.<LocalChannel>create());
            serverChannels.get(localAddress).set(serverChannel);

            p.addLast(new LoggingHandler("localServerBootstrp Handler 3", LogLevel.TRACE));

            // add remote device handler for route remote request
            p.addLast(remoteDeviceHandler);
            p.addLast(new LoggingHandler("localServerBootstrp Handler 2", LogLevel.TRACE));
            p.addLast(getMultiplexer());
            p.addLast(new LoggingHandler("localServerBootstrp Handler 1", LogLevel.TRACE));
        }
    });

    // Start the server.
    final ChannelFuture serverChannelFuture = localServerBootstrap.bind(localServerAddr);
    LOG.debug("serverChannel: " + serverChannelFuture);
}