code: private boolean invokeCleanups(Class<?> clazz, Object target,
                                     Class<?> cleanupClazz, Throwable exception) throws Exception {
          boolean invoked = false;
  
          if (!cleanupClazz.equals(Object.class)) {
              // Christian Beikov 29.07.2013: Traverse whole hierarchy
              // instead of retrieving the annotation directly from
              // the class object.
              List<Method> methods = ReflectionUtils.getMethods(target.getClass(), Cleanup.class);
              Method m = null;
  
              for (Method candidate : methods) {
                  Cleanup c = AnnotationUtils.findAnnotation(candidate, Cleanup.class);
  
                  if (cleanupClazz.equals(c.value())) {
                      m = candidate;
                      break;
                  }
              }
  
              if (m != null) {
                  final Class<?>[] parameterTypes = m.getParameterTypes();
                  if (parameterTypes.length == 1) {
                      if (ReflectionUtils.isSubtype(exception.getClass(), parameterTypes[0])) {
                          m.invoke(target, exception);
                          invoked = true;
                      } else {
                          throw new IllegalArgumentException("Cleanup method with name " + cleanupClazz.getName() + " requires a parameter that is not a subtype of the exception class " + exception.getClass().getName());
                      }
                  } else {
                      m.invoke(target);
                      invoked = true;
                  }
              }
          }
  
          return invoked;
      }
docs: Invokes the cleanup methods of the exception handler or exception
  handling.
  
  @param clazz       the class of the bean to get the methods from
  @param target      the target on which the method is invoked
  @param cleanupName the name of the cleanup method
  @return true if the cleanup method were found and invoked
  @throws Exception if an reflection specific exception occurs