package org.jfox.jetty;
import org.huihoo.jfox.system.ServiceSupport;
import org.mortbay.util.Log;
import org.mortbay.jetty.Server;
public class IntegrateJetty extends ServiceSupport {
private Server server = null;
private String conf = System.getProperty("jfox.home")+"/conf/jetty.xml";
private String home = "../";
public void setJettyHome(String dir){
home = dir;
}
public String getJettyHome(){
return home;
}
public void setConfig(String file){
conf = file;
}
public String getConfig(){
return conf;
}
protected void doInit() throws Exception {
System.setProperty("jetty.home",home);
JettyLogSink logSink = new JettyLogSink(logger);
logSink.start();
Log.instance().disableLog(); Log.instance().add(logSink);
}
protected void doStart() throws Exception {
server = new Server(conf);
server.start();
}
protected void doStop() throws Exception {
server.stop();
}
protected void doDestroy() throws Exception {
server.destroy();
server = null;
}
public void run() {
}
public static void main(String[] args) throws Exception {
System.setProperty("jfox.home","../");
System.setProperty("jetty.home","../");
IntegrateJetty ij = new IntegrateJetty();
ij.setConfig("../conf/jetty.xml");
ij.init();
ij.start();
}
}