Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. public void startServer(String address, int port) throws Exception {
  2.     Server server = new Server();
  3.    
  4.     ServerConnector c = new ServerConnector(server);
  5.     c.setIdleTimeout(1000);
  6.     c.setAcceptQueueSize(10);
  7.     c.setPort(port);
  8.     c.setHost(address);
  9.    
  10.    
  11.     WebAppContext webapp = new WebAppContext();
  12.     webapp.setResourceBase("src/main/webapp");
  13.     webapp.setConfigurations(new Configuration[]{
  14.       new WebInfConfiguration(),
  15.       new WebXmlConfiguration(),
  16.       new MetaInfConfiguration(),
  17.       new FragmentConfiguration(),
  18.       new EnvConfiguration(),
  19.       new PlusConfiguration(),
  20.       new AnnotationConfiguration(),
  21.       new JettyWebXmlConfiguration()});
  22.    
  23.     webapp.setContextPath("/myapp");
  24.     webapp.setParentLoaderPriority(true);
  25. //    webapp.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
  26. //            ".*/target/classes/");
  27.    
  28.     server.setHandler(webapp);
  29.     server.addConnector(c);
  30.     server.start();
  31.     server.join();
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement