Example usage for io.vertx.core.http HttpServerOptions setIdleTimeout

List of usage examples for io.vertx.core.http HttpServerOptions setIdleTimeout

Introduction

In this page you can find the example usage for io.vertx.core.http HttpServerOptions setIdleTimeout.

Prototype

@Override
    public HttpServerOptions setIdleTimeout(int idleTimeout) 

Source Link

Usage

From source file:com.dinstone.vertx.verticle.HttpManageVerticle.java

License:Apache License

private HttpServerOptions getRestHttpServerOptions() {
    HttpServerOptions serverOptions = null;
    try {/*  www .  j  a v  a2s  .  co m*/
        serverOptions = applicationContext.getBean("restHttpServerOptions", HttpServerOptions.class);
    } catch (Exception e) {
        // ignore
    }
    if (serverOptions == null) {
        serverOptions = new HttpServerOptions();
    }

    serverOptions.setIdleTimeout(manageProperties.getIdleTimeout());
    serverOptions.setPort(manageProperties.getPort());

    if (manageProperties.getHost() != null) {
        serverOptions.setHost(manageProperties.getHost());
    }
    return serverOptions;
}

From source file:com.dinstone.vertx.verticle.HttpRestVerticle.java

License:Apache License

private HttpServerOptions getRestHttpServerOptions() {
    HttpServerOptions serverOptions = null;
    try {/* ww  w . j  a v a2  s  .c  o  m*/
        serverOptions = applicationContext.getBean("restHttpServerOptions", HttpServerOptions.class);
    } catch (Exception e) {
        // ignore
    }
    if (serverOptions == null) {
        serverOptions = new HttpServerOptions();
    }

    serverOptions.setIdleTimeout(restProperties.getIdleTimeout());
    serverOptions.setPort(restProperties.getPort());

    if (restProperties.getHost() != null) {
        serverOptions.setHost(restProperties.getHost());
    }
    return serverOptions;
}

From source file:io.gravitee.am.gateway.vertx.VertxHttpServerFactory.java

License:Apache License

@Override
public HttpServer getObject() throws Exception {
    HttpServerOptions options = new HttpServerOptions();

    // Binding port
    options.setPort(httpServerConfiguration.getPort());
    options.setHost(httpServerConfiguration.getHost());

    // Netty pool buffers must be enabled by default
    options.setUsePooledBuffers(true);/*from w ww .j  a va 2  s  .  c o  m*/

    if (httpServerConfiguration.isSecured()) {
        options.setSsl(httpServerConfiguration.isSecured());
        options.setUseAlpn(httpServerConfiguration.isAlpn());

        if (httpServerConfiguration.isClientAuth()) {
            options.setClientAuth(ClientAuth.REQUIRED);
        }

        if (httpServerConfiguration.getTrustStorePath() != null) {
            options.setTrustStoreOptions(new JksOptions().setPath(httpServerConfiguration.getTrustStorePath())
                    .setPassword(httpServerConfiguration.getTrustStorePassword()));
        }

        if (httpServerConfiguration.getKeyStorePath() != null) {
            options.setKeyStoreOptions(new JksOptions().setPath(httpServerConfiguration.getKeyStorePath())
                    .setPassword(httpServerConfiguration.getKeyStorePassword()));
        }
    }

    // Customizable configuration
    options.setCompressionSupported(httpServerConfiguration.isCompressionSupported());
    options.setIdleTimeout(httpServerConfiguration.getIdleTimeout());
    options.setTcpKeepAlive(httpServerConfiguration.isTcpKeepAlive());

    return vertx.createHttpServer(options);
}

From source file:io.gravitee.gateway.standalone.vertx.VertxHttpServerFactory.java

License:Apache License

@Override
public HttpServer getObject() throws Exception {
    HttpServerOptions options = new HttpServerOptions();

    // Binding port
    options.setPort(httpServerConfiguration.getPort());

    // Netty pool buffers must be enabled by default
    options.setUsePooledBuffers(true);/*from   w  w  w  . j  a  v a2  s  . c om*/

    if (httpServerConfiguration.isSecured()) {
        options.setSsl(httpServerConfiguration.isSecured());

        if (httpServerConfiguration.isClientAuth()) {
            options.setClientAuth(ClientAuth.REQUIRED);
        }

        options.setTrustStoreOptions(new JksOptions().setPath(httpServerConfiguration.getKeyStorePath())
                .setPassword(httpServerConfiguration.getKeyStorePassword()));
        options.setKeyStoreOptions(new JksOptions().setPath(httpServerConfiguration.getTrustStorePath())
                .setPassword(httpServerConfiguration.getKeyStorePassword()));
    }

    // Customizable configuration
    options.setCompressionSupported(httpServerConfiguration.isCompressionSupported());
    options.setIdleTimeout(httpServerConfiguration.getIdleTimeout());
    options.setTcpKeepAlive(httpServerConfiguration.isTcpKeepAlive());

    return vertx.createHttpServer(options);
}

From source file:org.apache.servicecomb.transport.rest.vertx.RestServerVerticle.java

License:Apache License

private HttpServerOptions createDefaultHttpServerOptions() {
    HttpServerOptions serverOptions = new HttpServerOptions();
    serverOptions.setUsePooledBuffers(true);
    serverOptions.setIdleTimeout(TransportConfig.getConnectionIdleTimeoutInSeconds());
    serverOptions.setCompressionSupported(TransportConfig.getCompressed());
    serverOptions.setMaxHeaderSize(TransportConfig.getMaxHeaderSize());
    serverOptions.setMaxInitialLineLength(TransportConfig.getMaxInitialLineLength());
    if (endpointObject.isHttp2Enabled()) {
        serverOptions.setUseAlpn(TransportConfig.getUseAlpn()).setInitialSettings(
                new Http2Settings().setMaxConcurrentStreams(TransportConfig.getMaxConcurrentStreams()));
    }/*from w w w  .  ja va 2  s  .  c  om*/
    if (endpointObject.isSslEnabled()) {
        SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory(SSL_KEY, null);
        SSLOption sslOption;
        if (factory == null) {
            sslOption = SSLOption.buildFromYaml(SSL_KEY);
        } else {
            sslOption = factory.createSSLOption();
        }
        SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass());
        VertxTLSBuilder.buildNetServerOptions(sslOption, sslCustom, serverOptions);
    }

    return serverOptions;
}