1   package eu.fbk.dkm.pikes.tintop;
2   
3   import org.glassfish.grizzly.http.server.CLStaticHttpHandler;
4   import org.glassfish.grizzly.http.server.HttpServer;
5   import org.slf4j.Logger;
6   import org.slf4j.LoggerFactory;
7   
8   import java.io.IOException;
9   
10  /**
11   * Created by alessio on 11/05/16.
12   */
13  
14  public class ServerTest {
15  
16      private static final Logger LOGGER = LoggerFactory.getLogger(ServerTest.class);
17  
18      public static void main(String[] args) {
19  
20          HttpServer httpServer = HttpServer.createSimpleServer("localhost", 8080);
21  
22          httpServer.getServerConfiguration().addHttpHandler(
23                  new CLStaticHttpHandler(HttpServer.class.getClassLoader(), "webdemo/"), "/demo/");
24  
25          // Fix
26          // see: http://stackoverflow.com/questions/35123194/jersey-2-render-swagger-static-content-correctly-without-trailing-slash
27          httpServer.getServerConfiguration().addHttpHandler(
28                  new CLStaticHttpHandler(HttpServer.class.getClassLoader(), "webdemo/static/"), "/static/");
29  
30          try {
31              httpServer.start();
32              Thread.currentThread().join();
33          } catch (IOException e) {
34              e.printStackTrace();
35          } catch (InterruptedException e) {
36              e.printStackTrace();
37          }
38  
39      }
40  }