Example usage for io.netty.handler.logging LogLevel DEBUG

List of usage examples for io.netty.handler.logging LogLevel DEBUG

Introduction

In this page you can find the example usage for io.netty.handler.logging LogLevel DEBUG.

Prototype

LogLevel DEBUG

To view the source code for io.netty.handler.logging LogLevel DEBUG.

Click Source Link

Usage

From source file:org.wso2.netty.SecureProxyInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();

    // Add SSL handler first to encrypt and decrypt everything.
    // In this example, we use a bogus certificate in the server side
    // and accept any invalid certificates in the client side.
    // You will need something more complicated to identify both
    // and server in the real world.

    pipeline.addLast(new LoggingHandler(LogLevel.DEBUG));

    if (isSecureBackend) {
        LOGGER.info("Adding the SSL Handler to the pipeline");

        SSLEngine engine = SSLUtil.createClientSSLContext(trustStoreLocation, trustStorePassword)
                .createSSLEngine();/*from w ww .  jav  a  2s .  com*/
        engine.setUseClientMode(true);

        pipeline.addLast("ssl", new SslHandler(engine));
    }

    pipeline.addLast(new HexDumpProxyBackendHandler(inbound));
}

From source file:server.operation.OperationServer.java

License:Apache License

public void start() throws Exception {
    // Configure SSL.
    final SslContext sslCtx;
    if (SSL) {/*from ww  w  .  j  a va2 s. c o  m*/
        // ??   ?  ?? ? ?.
        //?, ??  ? .
        //jvm  ?? ?. (netty api )
        //SelfSignedCertificate ssc = new SelfSignedCertificate();
        //sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build();

        //File cert = new File("./resource/cert/nene.crt");
        //File privateKey= new File("./resource/cert/privatekey.pem");

        //resources/cert ? ?? ? ?? .
        //? pkcs#8? .
        final File cert = ResourceUtils.getFile("classpath:/cert/nene.crt");
        final File privateKey = ResourceUtils.getFile("classpath:/cert/nene.pem");
        sslCtx = SslContextBuilder.forServer(cert, privateKey, "tkfkdgo123!").build();
        System.out.println("ssl? ??. : " + SSL + ", port : " + PORT);

    } else {
        sslCtx = null;
    }

    // Configure the server.
    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
                .option(ChannelOption.SO_BACKLOG, 100).handler(new LoggingHandler(LogLevel.DEBUG))
                .childHandler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    public void initChannel(SocketChannel ch) throws Exception {
                        ChannelPipeline p = ch.pipeline();
                        if (sslCtx != null) {
                            p.addLast(sslCtx.newHandler(ch.alloc()));
                        }
                        p.addLast(new LoggingHandler(LogLevel.DEBUG),
                                //new StringEncoder(CharsetUtil.UTF_8),
                                //new LineBasedFrameDecoder(8192),
                                //new StringDecoder(CharsetUtil.UTF_8),
                                new ChunkedWriteHandler(),
                                new OperationServerHandler(applicationContext, eventPublisher));
                    }
                });

        // Start the server.
        ChannelFuture f = b.bind(PORT).sync();

        // Wait until the server socket is closed.
        //f.channel().closeFuture().sync();
    } finally {
        // Shut down all event loops to terminate all threads.
        //bossGroup.shutdownGracefully();
        //workerGroup.shutdownGracefully();
    }
}

From source file:server.telnet.TelnetServerInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) throws Exception {

    ChannelPipeline pipeline = ch.pipeline();

    if (sslCtx != null) {
        pipeline.addLast(sslCtx.newHandler(ch.alloc()));
    }/*  ww  w.j  a va  2 s .co m*/

    // Add the text line codec combination first,
    pipeline.addLast(new LoggingHandler(LogLevel.DEBUG));
    pipeline.addLast(new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
    // the encoder and decoder are static as these are sharable
    pipeline.addLast(DECODER);
    pipeline.addLast(ENCODER);

    // and then business logic.
    pipeline.addLast(SERVER_HANDLER);
}