Class TrackerProxy<T>

  • Type Parameters:
    T - bean type
    All Implemented Interfaces:
    org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor

    public class TrackerProxy<T>
    extends java.lang.Object
    implements org.aopalliance.intercept.MethodInterceptor
    AOP interceptor redirect calls from the real bean into spy object, which was created around the same real bean.

    There is a chicken-egg problem: service binding can't be overridden (with spy instance), because spy requires service instance for construction. So, instead of replacing bean, we intercept bean calls. Actual spy object is created lazily just after injector creation. On the first call, AOP interceptor breaks the current aop chain (if other interceptors registered) and redirect calls to spy, which again calls the same service (including aop handler), but, this time, it processes normally.

    • Constructor Summary

      Constructors 
      Constructor Description
      TrackerProxy​(java.lang.Class<T> type, TrackerConfig config, com.codahale.metrics.MetricRegistry metrics)
      Create proxy.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Tracker<T> getTracker()  
      java.lang.Object invoke​(org.aopalliance.intercept.MethodInvocation methodInvocation)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TrackerProxy

        public TrackerProxy​(java.lang.Class<T> type,
                            TrackerConfig config,
                            com.codahale.metrics.MetricRegistry metrics)
        Create proxy.
        Parameters:
        type - service type
        config - config
        metrics - metrics
    • Method Detail

      • getTracker

        public Tracker<T> getTracker()
        Returns:
        tracker instance
      • invoke

        public java.lang.Object invoke​(org.aopalliance.intercept.MethodInvocation methodInvocation)
                                throws java.lang.Throwable
        Specified by:
        invoke in interface org.aopalliance.intercept.MethodInterceptor
        Throws:
        java.lang.Throwable