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

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

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

revision 3211 by torben, Tue Jun 9 09:28:14 2015 UTC revision 3212 by torben, Thu Dec 28 09:34:47 2017 UTC
# Line 22  import java.lang.reflect.Method; Line 22  import java.lang.reflect.Method;
22    
23  import dk.thoerup.circuitbreaker.CircuitInvocation;  import dk.thoerup.circuitbreaker.CircuitInvocation;
24    
25  public class AnnotatedInvocation implements CircuitInvocation {  public class AnnotatedInvocation<T> implements CircuitInvocation<T> {
26                    
27          public static class CBAnnotationException extends Exception {          public static class CBAnnotationException extends Exception {
28                  public CBAnnotationException() {                  public CBAnnotationException() {
# Line 38  public class AnnotatedInvocation impleme Line 38  public class AnnotatedInvocation impleme
38                  this.obj = obj;                  this.obj = obj;
39          }          }
40    
41          public Object proceed() throws Exception {          @SuppressWarnings("unchecked")
42            public T proceed() throws Exception {
43                                    
44                  Method methods[] = obj.getClass().getMethods();                  Method methods[] = obj.getClass().getMethods();
45                  for(Method current : methods) {                  for(Method current : methods) {
# Line 47  public class AnnotatedInvocation impleme Line 48  public class AnnotatedInvocation impleme
48                                                    
49                          if (anno != null ) {                          if (anno != null ) {
50                                  try {                                  try {
51                                          return current.invoke(obj, (Object[])null); //invoke the first method annotated                                          return (T) current.invoke(obj, (Object[])null); //invoke the first method annotated
52                                  } catch (InvocationTargetException e) {                                  } catch (InvocationTargetException e) {
53                                          throw (Exception) e.getCause(); //unwrap any exception from InvocationTargetException                                          throw (Exception) e.getCause(); //unwrap any exception from InvocationTargetException
54                                  }                                  }

Legend:
Removed from v.3211  
changed lines
  Added in v.3212

  ViewVC Help
Powered by ViewVC 1.1.20