1 37 38 import org.mortbay.http.SocketListener; 39 import org.mortbay.jetty.Server; 40 import org.apache.log4j.Logger; 41 import java.io.IOException ; 42 43 import net.sourceforge.cruisecontrol.util.MainArgs; 44 45 50 public final class CruiseControlWithJetty { 51 private static final Logger LOG = Logger.getLogger(CruiseControlWithJetty.class); 52 53 private CruiseControlWithJetty() { } 54 55 static int parseWebPort(String [] args) { 56 return MainArgs.parseInt(args, "webport", 8080, 8080); 57 } 58 59 static String parseCCHome(String [] args) { 60 return MainArgs.parseArgument(args, "cchome", ".", "."); 61 } 62 63 static String parseCCName(String [] args) { 64 return MainArgs.parseArgument(args, "ccname", "", ""); 65 } 66 67 public static void main(final String [] args) throws Exception { 68 new Thread (new Runnable () { 70 public void run() { 71 Server server = new Server(); 72 SocketListener listener = new SocketListener(); 73 listener.setPort(parseWebPort(args)); 74 System.setProperty("ccname", parseCCName(args)); 75 server.addListener(listener); 76 try { 77 String webApp = parseCCHome(args) + "/webapps/cruisecontrol"; 78 server.addWebApplication("/cruisecontrol", webApp); 79 server.addWebApplication("/", webApp); 80 } catch (IOException e) { 81 String msg = "Exception adding cruisecontrol webapp: " + e.getMessage(); 82 LOG.error(msg, e); 83 throw new RuntimeException (msg); 84 } 85 try { 86 server.start(); 87 } catch (Exception e) { 88 String msg = "Exception occured in server execution: " + e.getMessage(); 89 LOG.error(msg, e); 90 throw new RuntimeException (); 91 } 92 } 93 }).start(); 94 95 new Thread (new Runnable () { 97 public void run() { 98 CruiseControl.main(args); 99 } 100 }).start(); 101 } 102 } 103
| Popular Tags
|