1 4 package com.tcspring; 5 6 import org.apache.commons.logging.Log; 7 import org.apache.commons.logging.LogFactory; 8 import org.springframework.aop.framework.AdvisedSupport; 9 import org.springframework.aop.framework.ProxyFactory; 10 import org.springframework.aop.framework.ProxyFactoryBean; 11 import org.springframework.beans.factory.BeanFactory; 12 13 import com.tc.aspectwerkz.joinpoint.StaticJoinPoint; 14 15 21 public class AopProxyFactoryProtocol { 22 private final transient Log logger = LogFactory.getLog(getClass()); 23 29 public Object createAopProxy(StaticJoinPoint jp, AdvisedSupport proxyFactory) throws Throwable { 30 ApplicationHelper applicationHelper = new ApplicationHelper(proxyFactory.getClass()); 31 if (!applicationHelper.isDSOApplication() || !applicationHelper.isFastProxyEnabled()) { return jp.proceed(); } 32 33 try { 34 if (proxyFactory instanceof ProxyFactoryBean) { 35 return new FastAopProxy((ProxyFactoryBean) proxyFactory); 36 } else if (proxyFactory instanceof ProxyFactory && proxyFactory.isFrozen()) { 37 return jp.proceed(); } else { 39 return jp.proceed(); 40 } 41 } catch (Throwable e) { 42 logger.warn("Falling back to using regular Spring AOP proxy creation, due to: " + e); 43 return jp.proceed(); 46 } 47 } 48 49 52 public void saveBeanFactory(BeanFactoryAware bean, BeanFactory beanFactory) throws Throwable { 53 bean.tc$setBeanFactory(beanFactory); 54 } 55 56 59 public static class BeanFactoryAwareMixin implements BeanFactoryAware { 60 private transient BeanFactory beanFactory; 61 62 public void tc$setBeanFactory(BeanFactory beanFactory) { 63 this.beanFactory = beanFactory; 64 } 65 66 public BeanFactory tc$getBeanFactory() { 67 return beanFactory; 68 } 69 } 70 71 } 72 73 | Popular Tags |