/[projects]/miscJava/CircuitBreaker/src/main/java/dk/thoerup/circuitbreaker/web/ActionCommand.java
ViewVC logotype

Annotation of /miscJava/CircuitBreaker/src/main/java/dk/thoerup/circuitbreaker/web/ActionCommand.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 418 - (hide annotations) (download)
Thu Oct 8 07:21:46 2009 UTC (14 years, 8 months ago) by torben
Original Path: CircuitBreaker/src/dk/thoerup/curcuitbreaker/web/ActionCommand.java
File size: 1312 byte(s)
Cleanup, remove unneeded import
1 torben 417 package dk.thoerup.curcuitbreaker.web;
2    
3     import java.io.IOException;
4     import java.net.URLEncoder;
5    
6     import javax.servlet.http.HttpServletRequest;
7     import javax.servlet.http.HttpServletResponse;
8    
9     import dk.thoerup.curcuitbreaker.AccountingCircuitBreaker;
10     import dk.thoerup.curcuitbreaker.CircuitBreaker;
11     import dk.thoerup.curcuitbreaker.CircuitBreakerManager;
12    
13     public class ActionCommand implements Command {
14    
15     private boolean readOnly;
16    
17     public ActionCommand(boolean readOnly) {
18     this.readOnly = readOnly;
19     }
20    
21     public String execute(HttpServletRequest req, HttpServletResponse resp) {
22     String action = req.getParameter("action");
23     String breaker = req.getParameter("breaker");
24    
25     CircuitBreaker cb = CircuitBreakerManager.getManager().getCircuitBreaker(breaker);
26    
27     if (readOnly == false) {
28     if (action.equalsIgnoreCase("reset"))
29     cb.reset();
30    
31     if (action.equalsIgnoreCase("tripbreaker"))
32     cb.tripBreaker();
33    
34     if (action.equalsIgnoreCase("resetcounters")) {
35     AccountingCircuitBreaker acb = (AccountingCircuitBreaker) cb;
36     acb.resetCounters();
37     }
38     }
39    
40     try {
41     String uri = req.getRequestURI() + "?command=view&breaker=" + URLEncoder.encode(breaker, "UTF-8");
42    
43     resp.sendRedirect( uri );
44     } catch(IOException e) {
45     // what should be done here ?
46     }
47     return "";
48     }
49    
50     }

  ViewVC Help
Powered by ViewVC 1.1.20