@Override
      public Object invoke(final Object thisObject, final Method method, final Object[] args)
          throws Throwable {

        // Don't intercept non-finder methods like equals and hashcode.
        if (!method.isAnnotationPresent(Finder.class)) {
          // This is not ideal, we are using the invocation handler's equals
          // and hashcode as a proxy (!) for the proxy's equals and hashcode.
          return method.invoke(this, args);
        }

        return finderProxy.invoke(new MethodInvocation() {
          @Override
          public Method getMethod() {
            return method;
          }

          @Override
          public Object[] getArguments() {
            return null == args ? new Object[0] : args;
          }

          @Override
          public Object proceed() throws Throwable {
            return method.invoke(thisObject, args);
          }

          @Override
          public Object getThis() {
            throw new UnsupportedOperationException("Bottomless proxies don't expose a this.");
          }

          @Override
          public AccessibleObject getStaticPart() {
            throw new UnsupportedOperationException();
          }
        });
      }
Adds an interface to this module to use as a dynamic finder.

@param iface Any interface type whose methods are all dynamic finders.
ambari-server/src/main/java/com/google/inject/persist/jpa/AmbariJpaPersistModule.java