Search in sources :

Example 1 with Configuration

use of hello.config.Configuration in project FrameworkBenchmarks by TechEmpower.

the class Main method main.

public static void main(String[] args) throws Throwable {
    Configuration config = Environment.load(args, Configuration.class);
    RestExpress server = new RestExpress().setName("RestExpress").setExecutorThreadCount(config.getExecutorThreadPoolSize()).setUseTcpNoDelay(true).setKeepAlive(true).noCompression().setEnforceHttpSpec(true).alias("HelloWorld", HelloWorld.class).addPostprocessor(new RequiredResponseHeaders());
    switch(config.getDatabase()) {
        case MongoDB:
            {
                server.uri("/plaintext", config.getPlaintextController()).action("sayHello", HttpMethod.GET).noSerialization();
                server.uri("/json", config.getJsonController()).action("sayHello", HttpMethod.GET);
                server.uri("/db", config.getMongodbController()).method(HttpMethod.GET);
                server.uri("/query", config.getQueriesMongodbController()).method(HttpMethod.GET);
            }
            break;
        case MySQL:
            {
                server.uri("/db", config.getMysqlController()).method(HttpMethod.GET);
                server.uri("/query", config.getQueriesMysqlController()).method(HttpMethod.GET);
            }
            break;
        default:
            throw new ConfigurationException("No Database configured in the environment.properties file.");
    }
    server.bind(config.getPort());
    server.awaitShutdown();
}
Also used : Configuration(hello.config.Configuration) ConfigurationException(org.restexpress.common.exception.ConfigurationException) RestExpress(org.restexpress.RestExpress) HelloWorld(hello.controller.JsonController.HelloWorld)

Aggregations

Configuration (hello.config.Configuration)1 HelloWorld (hello.controller.JsonController.HelloWorld)1 RestExpress (org.restexpress.RestExpress)1 ConfigurationException (org.restexpress.common.exception.ConfigurationException)1