20 |
* </pre> |
* </pre> |
21 |
*/ |
*/ |
22 |
|
|
23 |
public class CircuitBreakerServletBase extends javax.servlet.http.HttpServlet { |
public class CircuitBreakerServletBase extends javax.servlet.http.HttpServlet { |
24 |
|
|
25 |
private static final long serialVersionUID = 1L; |
private static final long serialVersionUID = 1L; |
26 |
|
|
27 |
|
private Command getCommand(String command) throws ServletException { |
28 |
|
if (command == null || command.equals("list")) |
29 |
|
return new ListCircuitBreakers(); |
30 |
|
|
31 |
|
if (command.equals("view")) |
32 |
|
return new ViewCircuitBreaker(); |
33 |
|
|
34 |
|
throw new ServletException("No such action:" + command); |
35 |
|
} |
36 |
|
|
37 |
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { |
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { |
38 |
ListCircuitBreakers cmd = new ListCircuitBreakers(); |
Command cmd = getCommand( req.getParameter("command")); |
39 |
|
|
40 |
String response = cmd.doCommand(req); |
String response = cmd.execute(req,resp); |
41 |
|
|
42 |
resp.setDateHeader("Expires", 0); |
resp.setDateHeader("Expires", 0); |
43 |
resp.setHeader("Pragma", "no-cache"); |
resp.setHeader("Pragma", "no-cache"); |
46 |
resp.getWriter().print(response); |
resp.getWriter().print(response); |
47 |
} |
} |
48 |
|
|
49 |
|
@Override |
50 |
|
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { |
51 |
|
doGet(req, resp); |
52 |
|
} |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
} |
} |