
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import org.mortbay.http.SocketListener;
import org.mortbay.jetty.Server;

import com.mysql.fabric.xmlrpc.base.Array;


public class AjaxJettyLauncher {
	protected int port = 8085;
	protected String contextName = "KAMS";
	protected String deployPath = "";
	
	public static void main(String[] args) throws Exception {
//	     String startNum="T4RG00418";
//	        String qz=startNum.substring(0,4);
//	        String sz=startNum.substring(4,startNum.length());
//	        Integer kssz=Integer.parseInt(sz);
//	        String endNum=String.format("%0"+sz.length()+"d",kssz+72-1);
//		System.out.println(qz+endNum);
		AjaxJettyLauncher jl = new AjaxJettyLauncher();
		jl.init();
		jl.run();
	}
	
	protected void init() {
	}
	
	protected void run() throws Exception {
		Server server = new Server();
		SocketListener listener = new SocketListener();
		listener.setPort(getPort()); server.addListener(listener);
		server.addWebApplication("/" + getContextName() , getDeployPath());
		server.start();
	}
	
	protected int getPort() {
		return port;
	}
	
	protected String getContextName() {
		return contextName;
		
	}
	
	protected String getDeployPath() {
		if (deployPath.length() == 0) {
			deployPath = "./target/" + contextName + "/";
		}
		return deployPath;
	}
}
