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
|
|
9 /**
|
|
10 * Hello world!
|
|
11 *
|
|
12 */
|
|
13 public class App
|
|
14 {
|
|
15 public static void main( String[] args ) throws Exception
|
|
16 {
|
|
17 BulletinBoard cassaBBS = null;
|
|
18 if(args.length == 0){
|
|
19 cassaBBS = new JungleBulletinBoard();
|
|
20 }else{
|
|
21 cassaBBS = new CassandraBulletinBoard("test-cluster","localhost:9160","cassaBBS2");
|
|
22 }
|
|
23
|
|
24
|
|
25 String createBoardMessagePath = "/createBoardMessage";
|
|
26 String createBoardPath = "/createBoard";
|
|
27 String editMessagePath = "/editMessage";
|
|
28 String showBoardMessagePath = "/showBoardMessage";
|
|
29
|
|
30 Servlet createBoardMessage = new CreateBoardMessageServlet(cassaBBS);
|
|
31 Servlet createBoard = new CreateBoardServlet(cassaBBS);
|
|
32 Servlet editBoardMessage = new EditMessageServlet(cassaBBS);
|
|
33 Servlet index = new ShowBoardsServlet(cassaBBS,createBoardPath,showBoardMessagePath);
|
|
34 Servlet board = new ShowBoardMessageServlet(cassaBBS,createBoardMessagePath,editMessagePath);
|
|
35
|
|
36 Server serv = new Server(8080);
|
|
37 ServletHandler context = new ServletHandler();
|
|
38 context.addServletWithMapping(new ServletHolder(createBoardMessage),createBoardMessagePath);
|
|
39 context.addServletWithMapping(new ServletHolder(createBoard),createBoardPath);
|
|
40 context.addServletWithMapping(new ServletHolder(editBoardMessage),editMessagePath);
|
|
41 context.addServletWithMapping(new ServletHolder(index),"/");
|
|
42 context.addServletWithMapping(new ServletHolder(board),showBoardMessagePath);
|
|
43 serv.addHandler(context);
|
|
44 serv.start();
|
|
45 }
|
|
46 }
|