annotate src/jungle/test/bbs/codesegment/StartBBSCodeSegment.java @ 53:f47a02368099

implemented timestamp in DefaultTreeOperationLogContainer
author one
date Sun, 14 Jul 2013 16:13:37 +0900
parents 61b2de3f7730
children 8a532ca5df80
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
44
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
1 package jungle.test.bbs.codesegment;
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
2
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
3 import java.util.regex.Pattern;
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
4 import java.util.regex.Matcher;
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
5
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
6 import javax.servlet.Servlet;
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
7
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
8 import jungle.test.bbs.BulletinBoard;
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
9 import jungle.test.bbs.CreateBoardMessageServlet;
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
10 import jungle.test.bbs.CreateBoardServlet;
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
11 import jungle.test.bbs.EditMessageServlet;
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
12 import jungle.test.bbs.NetworkJungleBulletinBoard;
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
13 import jungle.test.bbs.ShowBoardMessageServlet;
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
14 import jungle.test.bbs.ShowBoardsServlet;
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
15
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
16 import org.mortbay.jetty.Server;
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
17 import org.mortbay.jetty.servlet.ServletHandler;
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
18 import org.mortbay.jetty.servlet.ServletHolder;
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
19
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
20 import alice.codesegment.CodeSegment;
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
21 import alice.datasegment.CommandType;
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
22 import alice.datasegment.Receiver;
47
686057add8a4 confirmed LogUpdateCodeSegment
one
parents: 46
diff changeset
23 import alice.jungle.codesegment.LogUpdateCodeSegment;
52
61b2de3f7730 add HashSetDataSegment and HashLogUpdateCodeSegment.
one
parents: 50
diff changeset
24 import alice.jungle.datasegment.HashSetDataSegment;
44
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
25
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
26 public class StartBBSCodeSegment extends CodeSegment {
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
27
48
ab8c655ef457 implemented bbsPort setting
one
parents: 47
diff changeset
28 int bbsPort = 8080;
44
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
29 Receiver host = ids.create(CommandType.PEEK);
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
30 private Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
31
48
ab8c655ef457 implemented bbsPort setting
one
parents: 47
diff changeset
32 public StartBBSCodeSegment(int p) {
ab8c655ef457 implemented bbsPort setting
one
parents: 47
diff changeset
33 bbsPort = p;
ab8c655ef457 implemented bbsPort setting
one
parents: 47
diff changeset
34 host.setKey("host");
ab8c655ef457 implemented bbsPort setting
one
parents: 47
diff changeset
35 }
ab8c655ef457 implemented bbsPort setting
one
parents: 47
diff changeset
36
44
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
37 public StartBBSCodeSegment() {
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
38 host.setKey("host");
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
39 }
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
40
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
41 public void run() {
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
42 System.out.println("StartBBSCodeSegment");
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
43 String name = host.asString();
46
fd3643699f83 modified pom.xml. fix conflict log4j libraries
one
parents: 45
diff changeset
44 System.out.println("name : "+ name);
44
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
45 Matcher matcher = pattern.matcher(name);
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
46 matcher.find();
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
47 String type = matcher.group(1);
52
61b2de3f7730 add HashSetDataSegment and HashLogUpdateCodeSegment.
one
parents: 50
diff changeset
48
61b2de3f7730 add HashSetDataSegment and HashLogUpdateCodeSegment.
one
parents: 50
diff changeset
49
44
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
50 BulletinBoard cassaBBS = new NetworkJungleBulletinBoard(name);
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
51 String createBoardMessagePath = "/createBoardMessage";
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
52 String createBoardPath = "/createBoard";
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
53 String editMessagePath = "/editMessage";
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
54 String showBoardMessagePath = "/showBoardMessage";
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
55
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
56 Servlet createBoardMessage = new CreateBoardMessageServlet(cassaBBS);
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
57 Servlet createBoard = new CreateBoardServlet(cassaBBS);
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
58 Servlet editBoardMessage = new EditMessageServlet(cassaBBS);
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
59 Servlet index = new ShowBoardsServlet(cassaBBS,createBoardPath,showBoardMessagePath);
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
60 Servlet board = new ShowBoardMessageServlet(cassaBBS,createBoardMessagePath,editMessagePath);
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
61
48
ab8c655ef457 implemented bbsPort setting
one
parents: 47
diff changeset
62 Server serv = new Server(bbsPort);
44
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
63 ServletHandler context = new ServletHandler();
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
64 context.addServletWithMapping(new ServletHolder(createBoardMessage),createBoardMessagePath);
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
65 context.addServletWithMapping(new ServletHolder(createBoard),createBoardPath);
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
66 context.addServletWithMapping(new ServletHolder(editBoardMessage),editMessagePath);
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
67 context.addServletWithMapping(new ServletHolder(index),"/");
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
68 context.addServletWithMapping(new ServletHolder(board),showBoardMessagePath);
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
69 serv.addHandler(context);
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
70 try {
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
71 serv.start();
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
72 } catch (Exception e) {
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
73 e.printStackTrace();
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
74 }
49
a89c3539bff2 modified LogUpdateCodeSegment
one
parents: 48
diff changeset
75
50
459b50f1a6ee add ChildLogCheckCodeSegment.
one
parents: 49
diff changeset
76 new ChildLogCheckCodeSegment();
52
61b2de3f7730 add HashSetDataSegment and HashLogUpdateCodeSegment.
one
parents: 50
diff changeset
77 HashSetDataSegment hashLog = new HashSetDataSegment();
61b2de3f7730 add HashSetDataSegment and HashLogUpdateCodeSegment.
one
parents: 50
diff changeset
78 ods.put("hashLog", hashLog);
61b2de3f7730 add HashSetDataSegment and HashLogUpdateCodeSegment.
one
parents: 50
diff changeset
79
49
a89c3539bff2 modified LogUpdateCodeSegment
one
parents: 48
diff changeset
80 int num = new Integer(matcher.group(2));
a89c3539bff2 modified LogUpdateCodeSegment
one
parents: 48
diff changeset
81 if (num != 0) {
a89c3539bff2 modified LogUpdateCodeSegment
one
parents: 48
diff changeset
82 // try {Thread.sleep(100);} catch(Exception e) { e.printStackTrace(); }
50
459b50f1a6ee add ChildLogCheckCodeSegment.
one
parents: 49
diff changeset
83 new LogUpdateCodeSegment();
49
a89c3539bff2 modified LogUpdateCodeSegment
one
parents: 48
diff changeset
84 }
a89c3539bff2 modified LogUpdateCodeSegment
one
parents: 48
diff changeset
85
a89c3539bff2 modified LogUpdateCodeSegment
one
parents: 48
diff changeset
86
44
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
87
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
88 }
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
89
9202247e6077 added StartBBSCodeSegment
one
parents:
diff changeset
90 }