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

Diff of /miscJava/CircuitBreaker/src/main/java/dk/thoerup/circuitbreaker/CircuitBreaker.java

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

revision 443 by torben, Sun Oct 18 07:57:02 2009 UTC revision 456 by torben, Tue Oct 20 20:42:36 2009 UTC
# Line 31  import dk.thoerup.curcuitbreaker.notific Line 31  import dk.thoerup.curcuitbreaker.notific
31                  try {                  try {
32                          String s = (String) cb.invoke(new TestInvocation("http://rafiki/test"));                          String s = (String) cb.invoke(new TestInvocation("http://rafiki/test"));
33                          response.getWriter().print(s);                          response.getWriter().print(s);
34                  } catch (Throwable e) {                  } catch (Exception e) {
35                          logger.warning( e.getMessage() );                          logger.warning( e.getMessage() );
36                          response.sendError(500);                          response.sendError(500);
37                          return;                          return;
# Line 63  public class CircuitBreaker{ Line 63  public class CircuitBreaker{
63          }          }
64                    
65                    
66      public Object invoke(CircuitInvocation invocation) throws Throwable      public Object invoke(CircuitInvocation invocation) throws Exception
67      {      {
68          Object result = null;          Object result = null;
69          try          try
# Line 72  public class CircuitBreaker{ Line 72  public class CircuitBreaker{
72              result = invocation.proceed();              result = invocation.proceed();
73              getState().postInvoke(this);              getState().postInvoke(this);
74          }          }
75          catch(Throwable t)          catch(Exception e)
76          {          {
77              getState().onError(this, t);              getState().onError(this, e);
78              throw t;              throw e;
79          }          }
80          return result;          return result;
81      }      }
# Line 104  public class CircuitBreaker{ Line 104  public class CircuitBreaker{
104      public void reset() {      public void reset() {
105          synchronized(this) {          synchronized(this) {
106                  if (currentState != closed) { // TODO: Is this conditional necessary ??                  if (currentState != closed) { // TODO: Is this conditional necessary ??
107                            closed.resetFailureCount();
108                          currentState = closed;                          currentState = closed;
109                          notifier.sendNotification(name, Notifier.Event.BreakerReset);                          notifier.sendNotification(name, Notifier.Event.BreakerReset);
110                  }                  }
# Line 117  public class CircuitBreaker{ Line 118  public class CircuitBreaker{
118          }          }
119      }      }
120            
121        public boolean isClosed() {
122            return (getState() == closed);
123        }
124        
125        public boolean isOpen() {
126            return (getState() == open);
127        }
128        
129      public String getName() {      public String getName() {
130          return name;          return name;
131      }      }

Legend:
Removed from v.443  
changed lines
  Added in v.456

  ViewVC Help
Powered by ViewVC 1.1.20