Mercurial > hg > Database > jungle-network
comparison src/jungle/test/bbs/DistributeApp.java @ 42:4419ac56cbfd
implemented serverName filed
author | one |
---|---|
date | Thu, 11 Jul 2013 19:58:36 +0900 |
parents | 7e94de2d6bc0 |
children | fd3643699f83 |
comparison
equal
deleted
inserted
replaced
41:b8b9668da13c | 42:4419ac56cbfd |
---|---|
2 | 2 |
3 import javax.servlet.Servlet; | 3 import javax.servlet.Servlet; |
4 | 4 |
5 import jungle.test.bbs.codesegment.PutAnotherLogCodeSegment; | 5 import jungle.test.bbs.codesegment.PutAnotherLogCodeSegment; |
6 import jungle.test.bbs.codesegment.PutHostLogCodeSegment; | 6 import jungle.test.bbs.codesegment.PutHostLogCodeSegment; |
7 import jungle.test.bbs.codesegment.StartBBSCodeSegment; | |
7 | 8 |
8 import org.mortbay.jetty.Server; | 9 import org.mortbay.jetty.Server; |
9 import org.mortbay.jetty.servlet.ServletHandler; | 10 import org.mortbay.jetty.servlet.ServletHandler; |
10 import org.mortbay.jetty.servlet.ServletHolder; | 11 import org.mortbay.jetty.servlet.ServletHolder; |
11 | 12 |
12 import alice.daemon.AliceDaemon; | 13 import alice.daemon.AliceDaemon; |
13 import alice.datasegment.DataSegment; | 14 import alice.datasegment.DataSegment; |
14 import alice.jungle.codesegment.LogUpdateCodeSegment; | 15 import alice.jungle.codesegment.LogUpdateCodeSegment; |
15 import alice.jungle.remote.RemoteConfig; | 16 import alice.jungle.remote.RemoteConfig; |
17 import alice.topology.node.StartTopologyNode; | |
18 import alice.topology.node.TopologyNode; | |
16 | 19 |
17 /** | 20 /** |
18 * Hello world! | 21 * Hello world! |
19 * | 22 * |
20 */ | 23 */ |
21 public class DistributeApp | 24 public class DistributeApp |
22 { | 25 { |
23 public static void main( String[] args ) throws Exception | 26 public static void main( String[] args ) throws Exception |
24 { | 27 { |
25 BulletinBoard cassaBBS = null; | 28 |
26 cassaBBS = new NetworkJungleBulletinBoard(); | |
27 RemoteConfig conf = new RemoteConfig(args); | 29 RemoteConfig conf = new RemoteConfig(args); |
30 new TopologyNode(conf, new StartBBSCodeSegment()); | |
31 /* | |
28 if(conf.hostname == null) { | 32 if(conf.hostname == null) { |
29 /* Host Side */ | |
30 new AliceDaemon(conf).listen(); | 33 new AliceDaemon(conf).listen(); |
31 PutHostLogCodeSegment cs = new PutHostLogCodeSegment(); | 34 PutHostLogCodeSegment cs = new PutHostLogCodeSegment(); |
32 cs.arg1.setKey("local","log"); | 35 cs.arg1.setKey("local","log"); |
36 LogUpdateCodeSegment updateCS = new LogUpdateCodeSegment("local", "anotherLog"); | |
37 updateCS.arg1.setKey("local", "anotherLog"); | |
33 } else { | 38 } else { |
34 /* Client Side */ | |
35 DataSegment.connect(conf.key, "", conf.hostname, conf.connectPort); | 39 DataSegment.connect(conf.key, "", conf.hostname, conf.connectPort); |
36 LogUpdateCodeSegment cs = new LogUpdateCodeSegment(); | 40 PutAnotherLogCodeSegment cs = new PutAnotherLogCodeSegment(); |
37 cs.arg1.setKey("remote", "hostLog"); | 41 cs.arg1.setKey("local", "log"); |
38 PutAnotherLogCodeSegment cs2 = new PutAnotherLogCodeSegment(); | 42 LogUpdateCodeSegment updateCS = new LogUpdateCodeSegment("remote", "hostLog"); |
39 cs2.arg1.setKey("local", "log"); | 43 updateCS.arg1.setKey("remote", "hostLog"); |
40 } | 44 } |
41 | 45 */ |
42 | |
43 String createBoardMessagePath = "/createBoardMessage"; | |
44 String createBoardPath = "/createBoard"; | |
45 String editMessagePath = "/editMessage"; | |
46 String showBoardMessagePath = "/showBoardMessage"; | |
47 | |
48 Servlet createBoardMessage = new CreateBoardMessageServlet(cassaBBS); | |
49 Servlet createBoard = new CreateBoardServlet(cassaBBS); | |
50 Servlet editBoardMessage = new EditMessageServlet(cassaBBS); | |
51 Servlet index = new ShowBoardsServlet(cassaBBS,createBoardPath,showBoardMessagePath); | |
52 Servlet board = new ShowBoardMessageServlet(cassaBBS,createBoardMessagePath,editMessagePath); | |
53 | |
54 Server serv = new Server(8080); | |
55 ServletHandler context = new ServletHandler(); | |
56 context.addServletWithMapping(new ServletHolder(createBoardMessage),createBoardMessagePath); | |
57 context.addServletWithMapping(new ServletHolder(createBoard),createBoardPath); | |
58 context.addServletWithMapping(new ServletHolder(editBoardMessage),editMessagePath); | |
59 context.addServletWithMapping(new ServletHolder(index),"/"); | |
60 context.addServletWithMapping(new ServletHolder(board),showBoardMessagePath); | |
61 serv.addHandler(context); | |
62 serv.start(); | |
63 } | 46 } |
64 } | 47 } |