Examples of ServerBootstrap


Examples of io.netty.bootstrap.ServerBootstrap

        SslContext sslCtx = SslContext.newServerContext(cert, keyStore);

        bossGroup = new NioEventLoopGroup(1);
        workerGroup = new NioEventLoopGroup();

        server = new ServerBootstrap();
        server.group(bossGroup, workerGroup)
              .channel(NioServerSocketChannel.class)
              .option(ChannelOption.SO_BACKLOG, 100)
              .handler(new LoggingHandler(LogLevel.INFO))
              .childHandler(new BasicSSLServerInitializer(sslCtx));
View Full Code Here

Examples of io.netty.bootstrap.ServerBootstrap

  }
    }

    private void doRun(EventLoopGroup loupGroup, Class<? extends ServerChannel> serverChannelClass) throws InterruptedException {
  try {
      ServerBootstrap b = new ServerBootstrap();
      b.option(ChannelOption.SO_BACKLOG, 1024);
      b.option(ChannelOption.SO_REUSEADDR, true);
      b.group(loupGroup).channel(serverChannelClass).childHandler(new HelloServerInitializer(loupGroup.next()));
      b.option(ChannelOption.MAX_MESSAGES_PER_READ, Integer.MAX_VALUE);
      b.childOption(ChannelOption.ALLOCATOR, new PooledByteBufAllocator(true));
      b.childOption(ChannelOption.SO_REUSEADDR, true);
      b.childOption(ChannelOption.MAX_MESSAGES_PER_READ, Integer.MAX_VALUE);

      Channel ch = b.bind(port).sync().channel();
      ch.closeFuture().sync();
  } finally {
      loupGroup.shutdownGracefully().sync();
  }
    }
View Full Code Here

Examples of io.netty.bootstrap.ServerBootstrap

    this.port = port;
    this.eventLoopGroup = eventLoopGroup;
  }

  public synchronized void start() throws InterruptedException {
    final ServerBootstrap bootstrap = new ServerBootstrap();

    bootstrap.group(this.eventLoopGroup);
    bootstrap.channel(NioServerSocketChannel.class);
    bootstrap.childOption(ChannelOption.SO_KEEPALIVE, true);

    final MockApnsServer server = this;

    bootstrap.childHandler(new ChannelInitializer<SocketChannel>() {

      @Override
      protected void initChannel(final SocketChannel channel) throws Exception {
        channel.pipeline().addLast("ssl", new SslHandler(SSLTestUtil.createSSLEngineForMockServer()));
        channel.pipeline().addLast("encoder", new ApnsErrorEncoder());
        channel.pipeline().addLast("decoder", new ApnsPushNotificationDecoder());
        channel.pipeline().addLast("handler", new MockApnsServerHandler(server));
      }
    });

    this.channel = bootstrap.bind(this.port).await().channel();
  }
View Full Code Here

Examples of io.netty.bootstrap.ServerBootstrap

    this.port = port;
    this.eventLoopGroup = eventLoopGroup;
  }

  public synchronized void start() throws InterruptedException {
    final ServerBootstrap bootstrap = new ServerBootstrap();

    bootstrap.group(this.eventLoopGroup);
    bootstrap.channel(NioServerSocketChannel.class);

    final MockFeedbackServer server = this;
    bootstrap.childHandler(new ChannelInitializer<SocketChannel>() {

      @Override
      protected void initChannel(final SocketChannel channel) throws Exception {
        channel.pipeline().addLast("ssl", new SslHandler(SSLTestUtil.createSSLEngineForMockServer()));
        channel.pipeline().addLast("encoder", new ExpiredTokenEncoder());
        channel.pipeline().addLast("handler", new MockFeedbackServerHandler(server));
      }
    });

    this.channel = bootstrap.bind(this.port).await().channel();
  }
View Full Code Here

Examples of io.netty.bootstrap.ServerBootstrap

                                    + (securePort != null ? " secureServerPort " + securePort : "")
                    );

                    Channel httpChannel = null;
                    if (port != null) {
                        httpChannel = new ServerBootstrap()
                                .option(ChannelOption.SO_BACKLOG, 1024)
                                .childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
                                .group(bossGroup, workerGroup)
                                .channel(NioServerSocketChannel.class)
                                .childHandler(new MockServerInitializer(mockServerMatcher, logFilter, MockServer.this, false))
                                .bind(port)
                                .sync()
                                .channel();
                    }

                    Channel httpsChannel = null;
                    if (securePort != null) {
                        httpsChannel = new ServerBootstrap()
                                .option(ChannelOption.SO_BACKLOG, 1024)
                                .childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
                                .group(bossGroup, workerGroup)
                                .channel(NioServerSocketChannel.class)
                                .childHandler(new MockServerInitializer(mockServerMatcher, logFilter, MockServer.this, true))
View Full Code Here

Examples of io.netty.bootstrap.ServerBootstrap

    }

    private ChannelFuture createBootstrap(boolean condition, final ChannelInitializer<SocketChannel> childHandler, final Integer port, boolean autoRead) throws ExecutionException, InterruptedException {
        final SettableFuture<ChannelFuture> hasConnected = SettableFuture.create();
        if (condition) {
            new ServerBootstrap()
                    .group(bossGroup, workerGroup)
                    .channel(NioServerSocketChannel.class)
                    .childHandler(childHandler)
                    .option(ChannelOption.SO_BACKLOG, 1024)
                    .childOption(ChannelOption.AUTO_READ, autoRead)
View Full Code Here

Examples of io.netty.bootstrap.ServerBootstrap

    @PostConstruct
    public void startServer() throws InterruptedException {
        if (serverBootstrap == null) {
            try {
                serverBootstrap = new ServerBootstrap()
                        .group(new NioEventLoopGroup(1), new NioEventLoopGroup(1))
                        .channel(NioServerSocketChannel.class)
                        .childHandler(new ChannelInitializer<SocketChannel>() {
                            @Override
                            public void initChannel(SocketChannel ch) throws Exception {
View Full Code Here

Examples of io.netty.bootstrap.ServerBootstrap

            @Override
            public void run() {
                try {
                    logger.debug("STARTING SERVER FOR HTTP ON PORT: " + port);
                    ChannelFuture channelFutureHTTP = new ServerBootstrap()
                            .option(ChannelOption.SO_BACKLOG, 1024)
                            .group(bossGroup, workerGroup)
                            .channel(NioServerSocketChannel.class)
                            .childHandler(new ChannelInitializer<SocketChannel>() {
                                @Override
                                public void initChannel(SocketChannel ch) throws Exception {
                                    ChannelPipeline pipeline = ch.pipeline();

                                    pipeline.addLast("logger", new LoggingHandler("TEST_SERVER"));
                                    pipeline.addLast("codec", new HttpServerCodec());
                                    pipeline.addLast("chunk-aggregator", new HttpObjectAggregator(10 * 1024 * 1024));
                                    pipeline.addLast("handler", new TestServerHandler());
                                }
                            })
                            .bind(port).addListener(new ChannelFutureListener() {
                                @Override
                                public void operationComplete(ChannelFuture future) throws Exception {
                                    if (future.isSuccess()) {
                                        hasBoundToHTTPPort.set("CONNECTED");
                                    } else {
                                        hasBoundToHTTPPort.setException(future.cause());
                                    }
                                }
                            });

                    logger.debug("STARTING SERVER FOR HTTPS ON PORT: " + securePort);
                    ChannelFuture channelFutureHTTPS = new ServerBootstrap()
                            .option(ChannelOption.SO_BACKLOG, 1024)
                            .group(bossGroup, workerGroup)
                            .channel(NioServerSocketChannel.class)
                            .childHandler(new ChannelInitializer<SocketChannel>() {
                                @Override
View Full Code Here

Examples of io.netty.bootstrap.ServerBootstrap

         }
         channelClazz = NioServerSocketChannel.class;
         eventLoopGroup = new NioEventLoopGroup(threadsToUse, new HornetQThreadFactory("hornetq-netty-threads", true, getThisClassLoader()));
      }

      bootstrap = new ServerBootstrap();
      bootstrap.group(eventLoopGroup);
      bootstrap.channel(channelClazz);
      final SSLContext context;
      if (sslEnabled)
      {
View Full Code Here

Examples of io.netty.bootstrap.ServerBootstrap

         }
         channelClazz = NioServerSocketChannel.class;
         eventLoopGroup = new NioEventLoopGroup(threadsToUse, new HornetQThreadFactory("hornetq-netty-threads", true, getThisClassLoader()));
      }

      bootstrap = new ServerBootstrap();
      bootstrap.group(eventLoopGroup);
      bootstrap.channel(channelClazz);
      final SSLContext context;
      if (sslEnabled)
      {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.