Let's you add a interceptor to a existing object. It's possible to specify which methods the inteceptor should intercept and if no method is specified all methods will be intercepted. @param target object type @param objectToIntercept the object you what do add a intercept
(T objectToIntercept, Interceptor interceptor, Method... methodsToIntercept)
| 232 | * @return a proxy object with the interceptor added. |
| 233 | */ |
| 234 | public static <T> T intercept(T objectToIntercept, Interceptor interceptor, Method... methodsToIntercept) { |
| 235 | T proxy = InterceptableProxyFactory.createANewObjectProxyIfNeeded(objectToIntercept); |
| 236 | |
| 237 | addMethodInterceptor(proxy, interceptor, methodsToIntercept); |
| 238 | return proxy; |
| 239 | } |
| 240 | |
| 241 | private static <T> void addMethodInterceptor(T proxy, Interceptor interceptor, Method... methodsToIntercept) { |
| 242 | Interceptor interceptorToAdd = interceptor; |