Package hello

Source Code of hello.Main

package hello;

import hello.config.Configuration;
import hello.controller.JsonController.HelloWorld;

import java.io.FileNotFoundException;
import java.io.IOException;

import org.jboss.netty.handler.codec.http.HttpMethod;

import com.strategicgains.restexpress.RestExpress;
import com.strategicgains.restexpress.util.Environment;

public class Main
{
  public static void main(String[] args) throws Exception
  {
    Configuration config = loadEnvironment(args);
    RestExpress server = new RestExpress()
      .setName("RestExpress Benchmark")
        .setExecutorThreadCount(config.getExecutorThreadPoolSize())
        .alias("HelloWorld", HelloWorld.class);

    server.uri("/restexpress/json", config.getJsonController())
      .action("helloWorld", HttpMethod.GET);

    server.uri("/restexpress/mysql", config.getMysqlController())
      .method(HttpMethod.GET);

    server.uri("/restexpress/mongodb", config.getMongodbController())
        .method(HttpMethod.GET);

    server.bind(config.getPort());
    server.awaitShutdown();
  }

  private static Configuration loadEnvironment(String[] args)
  throws FileNotFoundException,
      IOException
  {
    if (args.length > 0)
    {
      return Environment.from(args[0], Configuration.class);
    }

    return Environment.fromDefault(Configuration.class);
  }
}
TOP

Related Classes of hello.Main

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.