Example usage for org.apache.http.impl.nio.bootstrap ServerBootstrap bootstrap

List of usage examples for org.apache.http.impl.nio.bootstrap ServerBootstrap bootstrap

Introduction

In this page you can find the example usage for org.apache.http.impl.nio.bootstrap ServerBootstrap bootstrap.

Prototype

public static ServerBootstrap bootstrap() 

Source Link

Usage

From source file:org.apache.http.localserver.AbstractAsyncTest.java

@Before
public void setUp() throws Exception {
    this.serverBootstrap = ServerBootstrap.bootstrap();
    final IOReactorConfig ioReactorConfig = IOReactorConfig.custom().setSoTimeout(15000).build();
    this.serverBootstrap.setServerInfo("TEST/1.1");
    this.serverBootstrap.setIOReactorConfig(ioReactorConfig);
    this.serverBootstrap.setExceptionLogger(new ExceptionLogger() {

        private final Log log = LogFactory.getLog(AbstractAsyncTest.class);

        @Override/* w  ww  .j a v  a2  s . c  o m*/
        public void log(final Exception ex) {
            log.error(ex.getMessage(), ex);
        }
    });
    if (this.scheme.equals(ProtocolScheme.https)) {
        this.serverBootstrap.setSslContext(createServerSSLContext());
    }

    final RegistryBuilder<SchemeIOSessionStrategy> builder = RegistryBuilder.create();
    builder.register("http", NoopIOSessionStrategy.INSTANCE);
    if (this.scheme.equals(ProtocolScheme.https)) {
        builder.register("https",
                new SSLIOSessionStrategy(createClientSSLContext(), new DefaultHostnameVerifier()));
    }
    final Registry<SchemeIOSessionStrategy> registry = builder.build();
    final DefaultConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(ioReactorConfig);
    this.connMgr = new PoolingNHttpClientConnectionManager(ioReactor, registry);
}

From source file:org.apache.http.nio.testserver.HttpServerNio.java

public void start() throws IOException {
    Asserts.check(this.server == null, "Server already running");
    this.server = ServerBootstrap.bootstrap()
            .setIOReactorConfig(IOReactorConfig.custom().setSoTimeout(this.timeout).build())
            .setServerInfo("TEST-SERVER/1.1").setConnectionFactory(connectionFactory)
            .setExceptionLogger(new SimpleExceptionLogger()).setExpectationVerifier(this.expectationVerifier)
            .setHttpProcessor(this.httpProcessor).setHandlerMapper(this.reqistry).create();
    this.server.start();
}