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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 416 by torben, Wed Oct 7 20:21:16 2009 UTC revision 417 by torben, Thu Oct 8 07:07:14 2009 UTC
# Line 18  import javax.servlet.http.*; Line 18  import javax.servlet.http.*;
18   *   private static final long serialVersionUID = 1L;   *   private static final long serialVersionUID = 1L;
19   * }   * }
20   * </pre>   * </pre>
21     *
22     * If you add a servlet init pameter to your deployment descriptor with the name 'readonly' and a integer value > 0,  you can disable the
23     * control buttons:
24     * <p>
25     *   &lt;init-param>&lt;param-name>readonly&lt;/param-name>&lt;param-value>1&lt;/param-value>&lt;/init-param>
26     *   <!-- <init-param><param-name>readonly</param-name><param-value>1</param-value></init-param> -->
27     *
28   */   */
29    
30  public class CircuitBreakerServletBase  extends javax.servlet.http.HttpServlet  {  public class CircuitBreakerServletBase  extends javax.servlet.http.HttpServlet  {
31                    
32          private static final long serialVersionUID = 1L;          private static final long serialVersionUID = 1L;
33                    
34            private boolean readOnly = false;
35            
36            
37            
38            @Override
39            public void init() throws ServletException {
40                    super.init();
41                    
42                    String readOnlyStr = getInitParameter("readonly");
43                    if (readOnlyStr != null && readOnlyStr.trim().length() >0) {
44                            int readOnlyInt = Integer.parseInt(readOnlyStr.trim());
45                            readOnly = (readOnlyInt > 0);
46                    }
47            }
48    
49          private Command getCommand(String command) throws ServletException {          private Command getCommand(String command) throws ServletException {
50                  if (command == null || command.equals("list"))                  if (command == null || command.equals("list"))
51                          return new ListCircuitBreakers();                          return new ListCircuitBreakers();
52                                    
53                  if (command.equals("view"))                  if (command.equals("view"))
54                          return new ViewCircuitBreaker();                          return new ViewCircuitBreaker(readOnly);
55                    if (command.equals("action"))
56                            return new ActionCommand(readOnly);
57                                    
58                  throw new ServletException("No such action:" + command);                  throw new ServletException("No such command:" + command);
59          }          }
60    
61          public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {          public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
# Line 50  public class CircuitBreakerServletBase Line 74  public class CircuitBreakerServletBase
74          protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {          protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
75                  doGet(req, resp);                  doGet(req, resp);
76          }          }
           
           
           
           
77    
78  }  }

Legend:
Removed from v.416  
changed lines
  Added in v.417

  ViewVC Help
Powered by ViewVC 1.1.20