1 25 26 package com.j2biz.blogunity.standalone; 27 28 import java.io.File ; 29 import java.io.FileInputStream ; 30 import java.util.Properties ; 31 32 import org.mortbay.http.SocketListener; 33 import org.mortbay.jetty.Server; 34 35 public class BlogunityServer { 36 37 private static int PORT = 8080; 38 39 private static String CONTEXT_PATH = "/"; 40 41 private static String WEBAPP_PATH = "./webapp"; 42 43 public static void main(String [] args) { 44 45 try { 46 47 int port = PORT; 48 String ctxpathStr = CONTEXT_PATH; 49 String webapppathStr = WEBAPP_PATH; 50 51 Properties configProps; 52 try { 53 File config = new File ("server.conf"); 54 FileInputStream in = new FileInputStream (config); 55 configProps = new Properties (); 56 configProps.load(in); 57 in.close(); 58 59 String portStr = configProps.getProperty("port"); 60 if (portStr != null && portStr.trim().length() > 0) { 61 try { 62 port = Integer.parseInt(portStr); 63 } catch (RuntimeException e1) { 64 port = PORT; 65 } 66 } 67 68 ctxpathStr = configProps.getProperty("contextPath"); 69 if (ctxpathStr == null || ctxpathStr.trim().length() <= 0) 70 ctxpathStr = CONTEXT_PATH; 71 72 webapppathStr = configProps.getProperty("webappPath"); 73 if (webapppathStr == null || webapppathStr.trim().length() <= 0) 74 webapppathStr = WEBAPP_PATH; 75 76 } catch (Exception e2) { 77 } 78 79 80 System.out.println("************************************"); 81 System.out.println("* Starting Blogunity-Standalone *"); 82 System.out.println("* Powered by Jetty HTTP-Server *"); 83 System.out.println("************************************"); 84 System.out.println("\nIf this is your first time starting standalone distribution,"); 85 System.out.println("please login as user 'admin' with password 'admin' into system"); 86 System.out.println("and change for safety reasons this login informations immediately."); 87 88 89 Server server = new Server(); 90 SocketListener listener = new SocketListener(); 91 listener.setPort(port); 92 server.addListener(listener); 93 94 server.addWebApplication(ctxpathStr, webapppathStr); 95 server.start(); 96 } catch (Exception e) { 97 e.printStackTrace(); 98 } 99 100 } 101 } | Popular Tags |