1 17 package org.apache.servicemix.web; 18 19 import org.mortbay.jetty.bio.SocketConnector; 20 import org.mortbay.jetty.webapp.WebAppContext; 21 import org.mortbay.jetty.Connector; 22 import org.mortbay.jetty.Handler; 23 import org.mortbay.jetty.Server; 24 25 30 public class JettyServer { 31 32 public static final int PORT = 8080; 33 34 public static final String WEBAPP_DIR = "src/webapp"; 35 36 public static final String WEBAPP_CTX = "/"; 37 38 public static void main(String [] args) throws Exception { 39 int port = PORT; 40 if (args.length > 0) { 41 String text = args[0]; 42 port = Integer.parseInt(text); 43 } 44 System.out.println("Starting Web Server on port: " + port); 45 Server server = new Server(); 46 SocketConnector connector = new SocketConnector(); 47 connector.setPort(port); 48 WebAppContext webapp = new WebAppContext(); 49 webapp.setContextPath(WEBAPP_CTX); 50 webapp.setResourceBase(WEBAPP_DIR); 51 server.setHandlers(new Handler[] { webapp }); 52 server.setConnectors(new Connector[] { connector }); 53 server.start(); 54 } 55 } 56 | Popular Tags |