Example #1
0
File: Server.java Project: lnx/dcos
 private static void start() {
   try {
     System.setProperty("file.encoding", encoding);
     String url = "http://" + ip;
     URI uri = UriBuilder.fromUri(url).port(port).build();
     ResourceConfig rc = new PackagesResourceConfig(packages);
     rc.add(new ApplicationHandler());
     HttpServer hs = GrizzlyServerFactory.createHttpServer(uri, rc);
     Log.info("Listening " + url + ":" + port);
     Log.info("Press enter key to exit...");
     System.in.read();
     hs.stop();
     Log.info("Bye!");
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
 @Override
 protected void before() throws Throwable {
   ResourceConfig rc = newConfig();
   server = GrizzlyServerFactory.createHttpServer(uri, rc);
 }