com.schlimm.springcdi.interceptor.processor
Class InterceptedBeanProxyAdvice

java.lang.Object
  extended by com.schlimm.springcdi.interceptor.processor.InterceptedBeanProxyAdvice
All Implemented Interfaces:
org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor

public class InterceptedBeanProxyAdvice
extends Object
implements org.aopalliance.intercept.MethodInterceptor

MethodInterceptor that is applied to any intercepted target bean. If a method call to the target bean is intercepted by user defined JSR 318 interceptors this advice creates a proxy for each target bean method that applies all the user defined JSR 318 interceptors. The method proxies are cached to maximize performance. Example: Bean ServiceImpl has a method called "sayHello()". The ServiceImpl has an InterceptorBinding declared that points to MyJSR318Interceptor. The the logic is as folows: The InterceptedBeanProxyAdvice is applied to ServiceImpl. If the sayHello() method is called the InterceptedBeanProxyAdvice creates a "method proxy", its target is ServiceImpl. The methid proxy applies the MyJSR318Interceptor advice. This logic is required 'cause every method on ServiceImple bean can have different interceptor chains, thus will have different method proxies that apply these chains.

Author:
Niklas Schlimm

Constructor Summary
InterceptedBeanProxyAdvice(org.springframework.beans.factory.BeanFactory beanFactory, InterceptorMetaDataBean metaDataBean, Object targetBean, String beanName)
           
 
Method Summary
 Object createProxyWithInterceptors(List<InterceptorInfo> interceptors)
           
static Map<String,Object> getCurrentContextData()
           
 List<InterceptorInfo> getInterceptors(org.aopalliance.intercept.MethodInvocation invocation)
           
 Object getProxy(org.aopalliance.intercept.MethodInvocation invocation)
          Get or create method proxy for the current MethodInvocation to the intercepted bean.
static Map<Method,Object> getProxyCache()
           
 Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
           
 Object performCall(org.aopalliance.intercept.MethodInvocation invocation, Object proxy)
           
static void resetProxyCache()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InterceptedBeanProxyAdvice

public InterceptedBeanProxyAdvice(org.springframework.beans.factory.BeanFactory beanFactory,
                                  InterceptorMetaDataBean metaDataBean,
                                  Object targetBean,
                                  String beanName)
Method Detail

invoke

public Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
              throws Throwable
Specified by:
invoke in interface org.aopalliance.intercept.MethodInterceptor
Throws:
Throwable

getProxy

public Object getProxy(org.aopalliance.intercept.MethodInvocation invocation)
Get or create method proxy for the current MethodInvocation to the intercepted bean.

Parameters:
invocation - current invocation
Returns:
method proxy that has all user defined interceptors applied

getInterceptors

public List<InterceptorInfo> getInterceptors(org.aopalliance.intercept.MethodInvocation invocation)

performCall

public Object performCall(org.aopalliance.intercept.MethodInvocation invocation,
                          Object proxy)

createProxyWithInterceptors

public Object createProxyWithInterceptors(List<InterceptorInfo> interceptors)

getCurrentContextData

public static Map<String,Object> getCurrentContextData()

getProxyCache

public static Map<Method,Object> getProxyCache()

resetProxyCache

public static void resetProxyCache()


Copyright © 2011. All Rights Reserved.