38
|
1 package jungle.test.bbs;
|
|
2
|
|
3 import javax.servlet.Servlet;
|
|
4
|
|
5 import org.mortbay.jetty.Server;
|
|
6 import org.mortbay.jetty.servlet.ServletHandler;
|
|
7 import org.mortbay.jetty.servlet.ServletHolder;
|
|
8
|
39
|
9 import alice.daemon.AliceDaemon;
|
|
10 import alice.datasegment.DataSegment;
|
|
11 import alice.jungle.codesegment.LogUpdateCodeSegment;
|
|
12 import alice.jungle.remote.RemoteConfig;
|
|
13
|
38
|
14 /**
|
|
15 * Hello world!
|
|
16 *
|
|
17 */
|
39
|
18 public class DistributeApp
|
38
|
19 {
|
|
20 public static void main( String[] args ) throws Exception
|
|
21 {
|
|
22 BulletinBoard cassaBBS = null;
|
39
|
23 cassaBBS = new NetworkJungleBulletinBoard();
|
|
24 RemoteConfig conf = new RemoteConfig(args);
|
|
25 new AliceDaemon(conf).listen();
|
|
26 if(conf.hostname != null) {
|
|
27 DataSegment.connect(conf.key, "", conf.hostname, conf.connectPort);
|
|
28 LogUpdateCodeSegment cs = new LogUpdateCodeSegment();
|
|
29 cs.arg1.setKey("remote", "log");
|
|
30
|
|
31 }
|
|
32
|
|
33
|
38
|
34 String createBoardMessagePath = "/createBoardMessage";
|
|
35 String createBoardPath = "/createBoard";
|
|
36 String editMessagePath = "/editMessage";
|
|
37 String showBoardMessagePath = "/showBoardMessage";
|
|
38
|
|
39 Servlet createBoardMessage = new CreateBoardMessageServlet(cassaBBS);
|
|
40 Servlet createBoard = new CreateBoardServlet(cassaBBS);
|
|
41 Servlet editBoardMessage = new EditMessageServlet(cassaBBS);
|
|
42 Servlet index = new ShowBoardsServlet(cassaBBS,createBoardPath,showBoardMessagePath);
|
|
43 Servlet board = new ShowBoardMessageServlet(cassaBBS,createBoardMessagePath,editMessagePath);
|
|
44
|
|
45 Server serv = new Server(8080);
|
|
46 ServletHandler context = new ServletHandler();
|
|
47 context.addServletWithMapping(new ServletHolder(createBoardMessage),createBoardMessagePath);
|
|
48 context.addServletWithMapping(new ServletHolder(createBoard),createBoardPath);
|
|
49 context.addServletWithMapping(new ServletHolder(editBoardMessage),editMessagePath);
|
|
50 context.addServletWithMapping(new ServletHolder(index),"/");
|
|
51 context.addServletWithMapping(new ServletHolder(board),showBoardMessagePath);
|
|
52 serv.addHandler(context);
|
|
53 serv.start();
|
|
54 }
|
|
55 }
|