-
Notifications
You must be signed in to change notification settings - Fork 0
/
EditorServer.java
40 lines (30 loc) · 1.24 KB
/
EditorServer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package web;
import com.mxgraph.canvas.mxGraphicsCanvas2D;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.HandlerList;
import org.mortbay.jetty.handler.ResourceHandler;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
public class EditorServer {
public static int PORT = 8090;
static {
mxGraphicsCanvas2D.HTML_SCALE = 0.75;
mxGraphicsCanvas2D.HTML_UNIT = "px";
}
public static void main(String[] args) throws Exception {
Server server = new Server(PORT);
Context context = new Context(server, "/");
context.addServlet(new ServletHolder(new EchoServlet()), "/save");
context.addServlet(new ServletHolder(new ExportServlet()), "/export");
context.addServlet(new ServletHolder(new OpenServlet()), "/open");
ResourceHandler fileHandler = new ResourceHandler();
fileHandler.setResourceBase(".");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { fileHandler, context });
server.setHandler(handlers);
System.out.println("Go to http://localhost:" + PORT + "/src/main/www/index.html");
server.start();
server.join();
}
}