2024-11-13 16:29:35 +08:00
|
|
|
import com.dev.energy.client.utils.StringUtils;
|
2024-08-03 15:32:07 +08:00
|
|
|
import org.mortbay.http.SocketListener;
|
|
|
|
|
import org.mortbay.jetty.Server;
|
|
|
|
|
|
|
|
|
|
public class AjaxJettyLauncher {
|
|
|
|
|
protected int port = 8088;
|
|
|
|
|
protected String contextName = "thtms";
|
2024-11-13 16:29:35 +08:00
|
|
|
protected String deployPath = null;
|
|
|
|
|
|
2024-08-03 15:32:07 +08:00
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
|
AjaxJettyLauncher jl = new AjaxJettyLauncher();
|
|
|
|
|
jl.run();
|
|
|
|
|
}
|
2024-11-13 16:29:35 +08:00
|
|
|
|
2024-08-03 15:32:07 +08:00
|
|
|
protected void init() {
|
|
|
|
|
}
|
2024-11-13 16:29:35 +08:00
|
|
|
|
2024-08-03 15:32:07 +08:00
|
|
|
protected void run() throws Exception {
|
|
|
|
|
Server server = new Server();
|
|
|
|
|
SocketListener listener = new SocketListener();
|
2024-11-13 16:29:35 +08:00
|
|
|
listener.setPort(getPort());
|
2024-08-03 15:32:07 +08:00
|
|
|
server.addListener(listener);
|
|
|
|
|
server.addWebApplication("/" + getContextName() , getDeployPath());
|
|
|
|
|
server.start();
|
|
|
|
|
}
|
2024-11-13 16:29:35 +08:00
|
|
|
|
2024-08-03 15:32:07 +08:00
|
|
|
protected int getPort() {
|
|
|
|
|
return port;
|
|
|
|
|
}
|
2024-11-13 16:29:35 +08:00
|
|
|
|
2024-08-03 15:32:07 +08:00
|
|
|
protected String getContextName() {
|
|
|
|
|
return contextName;
|
|
|
|
|
}
|
2024-11-13 16:29:35 +08:00
|
|
|
|
2024-08-03 15:32:07 +08:00
|
|
|
protected String getDeployPath() {
|
2024-11-13 16:29:35 +08:00
|
|
|
if (StringUtils.isEmpty(deployPath)) {
|
2024-08-03 15:32:07 +08:00
|
|
|
deployPath = "./target/" + contextName + "/";
|
|
|
|
|
}
|
|
|
|
|
return deployPath;
|
|
|
|
|
}
|
|
|
|
|
}
|