Class TrackerProxy<T>
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.test.track.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.MethodInterceptorAOP 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.Objectinvoke(org.aopalliance.intercept.MethodInvocation methodInvocation)
-
-
-
Constructor Detail
-
TrackerProxy
public TrackerProxy(java.lang.Class<T> type, TrackerConfig config, com.codahale.metrics.MetricRegistry metrics)
Create proxy.- Parameters:
type- service typeconfig- configmetrics- metrics
-
-