use of org.restexpress.common.exception.ConfigurationException 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();
}
use of org.restexpress.common.exception.ConfigurationException in project FrameworkBenchmarks by TechEmpower.
the class MysqlConfig method configureMysqlConnections.
private MysqlConnectionPoolDataSource configureMysqlConnections(String uri, String dbUser, String dbPassword, String useConfigs) {
MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
ds.setUrl(uri);
if (dbUser != null) {
ds.setUser(dbUser);
}
if (dbPassword != null) {
ds.setPassword(dbPassword);
}
if (useConfigs != null) {
try {
ds.setUseConfigs(useConfigs);
} catch (java.sql.SQLException e) {
throw new ConfigurationException("Unable to set DataSource config", e);
}
}
return ds;
}
Aggregations