--- CircuitBreaker/src/dk/thoerup/curcuitbreaker/web/CircuitBreakerServletBase.java 2009/10/07 19:24:34 415 +++ CircuitBreaker/src/dk/thoerup/curcuitbreaker/web/CircuitBreakerServletBase.java 2009/10/07 20:21:16 416 @@ -20,14 +20,24 @@ * */ -public class CircuitBreakerServletBase extends javax.servlet.http.HttpServlet { +public class CircuitBreakerServletBase extends javax.servlet.http.HttpServlet { private static final long serialVersionUID = 1L; + + private Command getCommand(String command) throws ServletException { + if (command == null || command.equals("list")) + return new ListCircuitBreakers(); + + if (command.equals("view")) + return new ViewCircuitBreaker(); + + throw new ServletException("No such action:" + command); + } public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - ListCircuitBreakers cmd = new ListCircuitBreakers(); + Command cmd = getCommand( req.getParameter("command")); - String response = cmd.doCommand(req); + String response = cmd.execute(req,resp); resp.setDateHeader("Expires", 0); resp.setHeader("Pragma", "no-cache"); @@ -36,4 +46,13 @@ resp.getWriter().print(response); } + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + doGet(req, resp); + } + + + + + }