I'm using Spring 3.0.6, and have created a Spring profiling aspect that I am applying to a significant number of beans using JDK proxies.
However, due to the need to access protected methods in one particular bean, I would like to advise it using CGLIB. All other beans I would like to continue to use JDK Proxies.
I am using a mix of annotations and xml configuration, but this particular aspect is defined in XML configuration.
I know that there is <aop:scoped-proxy> tag, but from what I can tell, that applies to all aspects.
Is there anyway to define for a single aspect to use CGLIB instead?
I've tried to split the configuration into two, and for one configuration specify target-class="true" and the other target-class="false", but it seems to apply CGLIB to all at that point.
<aop:aspect id="Profiler" ref="lendingSimulationServiceProfilerInterceptor">
<!-- info -->
pointcut="execution(* com.cws.cs.lendingsimulationservice.service.LendingSimulationServiceImpl.calculate*(..))" />
<!-- debug -->
pointcut="execution(* com.cws.cs.lendingsimulationservice.process.LendingSimulationProcessImpl.calculate(..))" />
pointcut="execution(* com.blaze.BlazeEngine.invokeService(..))" />
<!-- trace -->
pointcut="execution(* com.calculator.dao.impl.LendingSimulationDaoImpl.*(..))" />
<!-- NEED TO DEFINE THIS PARTICULAR ASPECT AS CGLIB -->
pointcut="execution(* com.cws.cs.lendingsimulationservice.util.pool.JAXBPoolImpl.*(..))" />
From further reading the Spring docs, I found the following note
I also found a reference indicating that someone managed to succeed by using a BeanNameAutoProxyCreator, but they didn't give any example and I am not entirely sure how that works.
Multiple <aop:config/> sections are collapsed into a single unified auto-proxy creator at runtime, which applies the strongest proxy settings that any of the <aop:config/> sections (typically from different XML bean definition files) specified. This also applies to the <tx:annotation-driven/> and <aop:aspectj-autoproxy/> elements.
To be clear: using 'proxy-target-class="true"' on <tx:annotation-driven/>, <aop:aspectj-autoproxy/> or <aop:config/> elements will force the use of CGLIB proxies for all three of them.
Is there anyone that can help me out?