/[projects]/CircuitBreaker/src/dk/thoerup/curcuitbreaker/web/CircuitBreakerServletBase.java
ViewVC logotype

Contents of /CircuitBreaker/src/dk/thoerup/curcuitbreaker/web/CircuitBreakerServletBase.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 416 - (show annotations) (download)
Wed Oct 7 20:21:16 2009 UTC (14 years, 7 months ago) by torben
File size: 1722 byte(s)
Sync
1 package dk.thoerup.curcuitbreaker.web;
2
3 import java.io.IOException;
4
5 import javax.servlet.ServletException;
6 import javax.servlet.http.*;
7
8 /**
9 * This is a web interface for viewing and controlling the CircuitBreakers currently registered in CircuitBreakerManager
10 * <p>
11 * To use this servlet in you .war module just create a simple servlet that extends this class (instead of HttpServlet)
12 * The new custom servlet doesn't need to implement any of the standard servlet methods - its all done in this implementation.
13 *
14 * <p>
15 * Example:
16 * <pre>
17 * public class CircuitBreakerServlet extends CircuitBreakerServletBase {
18 * private static final long serialVersionUID = 1L;
19 * }
20 * </pre>
21 */
22
23 public class CircuitBreakerServletBase extends javax.servlet.http.HttpServlet {
24
25 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 {
38 Command cmd = getCommand( req.getParameter("command"));
39
40 String response = cmd.execute(req,resp);
41
42 resp.setDateHeader("Expires", 0);
43 resp.setHeader("Pragma", "no-cache");
44 resp.setHeader("Cache-Control", "no-cache");
45
46 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 }

Properties

Name Value
svn:mergeinfo

  ViewVC Help
Powered by ViewVC 1.1.20