Mercurial > hg > Database > jungle-network
view src/jungle/test/bbs/codesegment/StartBBSCodeSegment.java @ 47:686057add8a4
confirmed LogUpdateCodeSegment
author | one |
---|---|
date | Fri, 12 Jul 2013 11:45:12 +0900 |
parents | fd3643699f83 |
children | ab8c655ef457 |
line wrap: on
line source
package jungle.test.bbs.codesegment; import java.util.regex.Pattern; import java.util.regex.Matcher; import javax.servlet.Servlet; import jungle.test.bbs.BulletinBoard; import jungle.test.bbs.CreateBoardMessageServlet; import jungle.test.bbs.CreateBoardServlet; import jungle.test.bbs.EditMessageServlet; import jungle.test.bbs.JungleManager; import jungle.test.bbs.NetworkJungleBulletinBoard; import jungle.test.bbs.ShowBoardMessageServlet; import jungle.test.bbs.ShowBoardsServlet; import org.mortbay.jetty.Server; import org.mortbay.jetty.servlet.ServletHandler; import org.mortbay.jetty.servlet.ServletHolder; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; import alice.jungle.codesegment.LogUpdateCodeSegment; public class StartBBSCodeSegment extends CodeSegment { Receiver host = ids.create(CommandType.PEEK); private Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$"); public StartBBSCodeSegment() { host.setKey("host"); } public void run() { System.out.println("StartBBSCodeSegment"); String name = host.asString(); System.out.println("name : "+ name); Matcher matcher = pattern.matcher(name); matcher.find(); String type = matcher.group(1); int num = new Integer(matcher.group(2)); LogUpdateCodeSegment cs = new LogUpdateCodeSegment(); cs.arg1.setKey("log", 0); BulletinBoard cassaBBS = new NetworkJungleBulletinBoard(name); String createBoardMessagePath = "/createBoardMessage"; String createBoardPath = "/createBoard"; String editMessagePath = "/editMessage"; String showBoardMessagePath = "/showBoardMessage"; Servlet createBoardMessage = new CreateBoardMessageServlet(cassaBBS); Servlet createBoard = new CreateBoardServlet(cassaBBS); Servlet editBoardMessage = new EditMessageServlet(cassaBBS); Servlet index = new ShowBoardsServlet(cassaBBS,createBoardPath,showBoardMessagePath); Servlet board = new ShowBoardMessageServlet(cassaBBS,createBoardMessagePath,editMessagePath); Server serv = new Server(8080); ServletHandler context = new ServletHandler(); context.addServletWithMapping(new ServletHolder(createBoardMessage),createBoardMessagePath); context.addServletWithMapping(new ServletHolder(createBoard),createBoardPath); context.addServletWithMapping(new ServletHolder(editBoardMessage),editMessagePath); context.addServletWithMapping(new ServletHolder(index),"/"); context.addServletWithMapping(new ServletHolder(board),showBoardMessagePath); serv.addHandler(context); try { serv.start(); } catch (Exception e) { e.printStackTrace(); } } }