/[projects]/android/TrainInfoService/src/dk/thoerup/traininfoservice/CircuitBreakerListener.java
ViewVC logotype

Contents of /android/TrainInfoService/src/dk/thoerup/traininfoservice/CircuitBreakerListener.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 866 - (show annotations) (download)
Sun Jun 20 22:10:29 2010 UTC (13 years, 10 months ago) by torben
File size: 1696 byte(s)
remove bane.dk circuitbreaker when undeploying
1 package dk.thoerup.traininfoservice;
2
3 import java.util.logging.Logger;
4
5 import javax.servlet.ServletContextEvent;
6 import javax.servlet.ServletContextListener;
7
8 import dk.thoerup.circuitbreaker.AccountingCircuitBreaker;
9 import dk.thoerup.circuitbreaker.CircuitBreakerManager;
10 import dk.thoerup.circuitbreaker.jmx.JMXWrapper;
11 import dk.thoerup.circuitbreaker.notification.JavaLogNotifier;
12
13 /**
14 * Application Lifecycle Listener implementation class JmxListener
15 *
16 */
17 public class CircuitBreakerListener implements ServletContextListener {
18
19 Logger logger = Logger.getLogger(CircuitBreakerListener.class.getName());
20
21 public CircuitBreakerListener() {
22 }
23
24 /**
25 * @see ServletContextListener#contextInitialized(ServletContextEvent)
26 */
27 public void contextInitialized(ServletContextEvent sce) {
28 logger.warning("Context Init");
29
30 int threshold = Integer.parseInt(sce.getServletContext().getInitParameter("banedk_threshold") );
31 int timeout = Integer.parseInt( sce.getServletContext().getInitParameter("banedk_timeout") );
32 CircuitBreakerManager mgr = CircuitBreakerManager.getManager();
33
34 AccountingCircuitBreaker banedk = new AccountingCircuitBreaker("banedk", threshold, timeout);
35 banedk.setNotifier( new JavaLogNotifier() );
36 mgr.addCircuitBreaker( banedk );
37
38 JMXWrapper.registerAllCircuitBreakers();
39 }
40
41 /**
42 * @see ServletContextListener#contextDestroyed(ServletContextEvent)
43 */
44 public void contextDestroyed(ServletContextEvent sce) {
45 logger.warning("Context Destroyed");
46 CircuitBreakerManager.getManager().removeCircuitBreaker("banedk");
47
48 JMXWrapper.unregisterAllCircuitBreakers();
49 }
50
51 }

  ViewVC Help
Powered by ViewVC 1.1.20