Class ApiFindInterceptor

java.lang.Object
com.bld.proxy.api.find.intecerptor.ApiFindInterceptor
All Implemented Interfaces:
InvocationHandler

@Component public class ApiFindInterceptor extends Object implements InvocationHandler
JDK InvocationHandler that serves as the entry point for every proxied controller method call in the proxy-api-controller framework.

This component is set as the InvocationHandler for every dynamic proxy registered by ApiFindRegistrar. On each method invocation it retrieves a prototype-scoped FindInterceptor bean from the Spring context (ensuring thread-safety and request isolation) and delegates the actual query execution to it.

The hashCode method is short-circuited and returns 0 to avoid infinite proxy recursion when the bean is stored in hash-based collections.

Author:
Francesco Baldi
See Also:
  • Constructor Details

    • ApiFindInterceptor

      public ApiFindInterceptor()
  • Method Details

    • invoke

      public Object invoke(Object obj, Method method, Object[] args) throws Throwable
      Intercepts every method call on a proxied @ApiFindController interface.

      Retrieves a fresh prototype FindInterceptor bean for each invocation and delegates to FindInterceptor.find(Object, Method, Object[]).

      Specified by:
      invoke in interface InvocationHandler
      Parameters:
      obj - the proxy instance
      method - the interface method that was invoked
      args - the runtime arguments supplied to the method call
      Returns:
      the query result produced by the FindInterceptor
      Throws:
      Throwable - if the underlying query or mapping fails