ZhongWei_Old2/src/main/java/AjaxJettyLauncher.java

54 lines
1.3 KiB
Java
Raw Normal View History

2024-12-18 10:38:31 +08:00
import com.dev.energy.client.utils.StringUtils;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
2024-12-18 10:38:31 +08:00
import org.mortbay.http.SocketListener;
import org.mortbay.jetty.Server;
public class AjaxJettyLauncher {
protected int port = 8080;
protected String contextName = "zwwms";
protected String deployPath = null;
private static Logger logger = Logger.getLogger(AjaxJettyLauncher.class);
2024-12-18 10:38:31 +08:00
public static void main(String[] args) throws Exception {
String currentDir = System.getProperty("user.dir");
logger.info("当前根目录是: " + currentDir);
PropertyConfigurator.configure("log4j.properties");
2024-12-18 10:38:31 +08:00
AjaxJettyLauncher jl = new AjaxJettyLauncher();
jl.run();
2024-12-18 10:38:31 +08:00
}
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();
logger.error("1232221231");
2024-12-18 10:38:31 +08:00
}
protected int getPort() {
return port;
}
protected String getContextName() {
return contextName;
}
protected String getDeployPath() {
if (StringUtils.isEmpty(deployPath)) {
deployPath = "./target/" + contextName + "/";
}
return deployPath;
}
}