List of usage examples for io.netty.channel ChannelHandler ChannelHandler
ChannelHandler
From source file:io.crate.plugin.PipelineRegistryTest.java
License:Apache License
private static PipelineRegistry.ChannelPipelineItem channelPipelineItem(String base, String name) { return new PipelineRegistry.ChannelPipelineItem(base, name, () -> new ChannelHandler() { @Override/*from ww w.j a v a 2 s . co m*/ public void handlerAdded(ChannelHandlerContext ctx) throws Exception { } @Override public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { } @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { } }); }
From source file:org.helios.octo.server.OctoServer.java
License:Open Source License
/** * <p>Starts the OctoServer</p> * @throws Exception Thrown on any error *//*from www.j a v a 2 s. c om*/ protected void startService() throws Exception { log.info( "\n\t===========================================\n\tStarting OctoServer\n\t==========================================="); InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory()); initClassLoader(); log.info("Starting listener on [" + address + ":" + port + "]"); bossGroup = new NioEventLoopGroup(); workerGroup = new NioEventLoopGroup(); channelGroup = new DefaultChannelGroup(workerGroup.next()); ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .localAddress(new InetSocketAddress(address, port)).childHandler(new ChannelHandler() { @Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { channelGroup.add(ctx.channel()); } @Override public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { /* No Op */ } @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { log.error("Exception caught in client pipeline", cause); } }).childHandler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) throws Exception { //ch.pipeline().addLast("logging", logging); ch.pipeline().addLast("objectDecoder", new ObjectDecoder(classResolver)); //ch.pipeline().addLast("objectEncoder", objectEncoder); ch.pipeline().addLast("logging", logging); ch.pipeline().addLast("out", outAdapter); ch.pipeline().addLast("stringEncoder", new StringEncoder()); //ch.pipeline().addLast("err", errAdapter); ch.pipeline().addLast("invHandler", invocationHandler); } }); b.bind().addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture f) throws Exception { if (f.isSuccess()) { serverChannel = (NioServerSocketChannel) f.channel(); closeFuture = serverChannel.closeFuture(); log.info("Started and listening on " + serverChannel.localAddress()); if (!SystemStreamRedirector.isInstalledOnCurrentThread()) { SystemStreamRedirector.install(); } log.info( "\n\t===========================================\n\tStarted OctoServer\n\t==========================================="); } } }); }
From source file:org.kaazing.messaging.driver.transport.netty.udp.NettyTransportContext.java
License:Apache License
public NettyTransportContext() { super();//from ww w . j a v a 2 s .c o m bootstrap = new Bootstrap(); group = new NioEventLoopGroup(); bootstrap.group(group).channel(NioDatagramChannel.class).handler(new ChannelHandler() { @Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { LOGGER.debug("Handler added with ctx {}", ctx); } @Override public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { LOGGER.debug("Handler removed with ctx {}", ctx); } @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { LOGGER.debug("exceptionCaught {}", ctx, cause); } }); }