I'm sort of new to the AOP scene and I haven't found much in spring documentation on intercepting protected methods or even if that was possible.
I have an example program that uses spring's AOP system and it appears that the cglib-modded classes do not forward protected method calls between instances of classes in the same package. From this, I gather that spring's AOP is not as transparent as it should be (assuming AOP was supposed to be transparent to start) or is this a side effect of the interface enforced development style? Conscious decision not to support this? Something else perhaps?
Code:package org.sample.spring; public class SimpleBean { AnotherSimpleBean asb; public void setAsb(AnotherSimpleBean asb) { this.asb = asb; } public String getValue() { return this.asb.getComputedValue(); } }Code:package org.sample.spring; public class AnotherSimpleBean { private String value; public void setValue(String value) { this.value = value; } protected String getComputedValue() { return this.value + this.value; } }Code:<?xml version="1.0"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="simplebeanTarget" class="org.sample.spring.SimpleBean" singleton="false"> <property name="asb"> <ref bean="anothersimplebean"/> </property> </bean> <bean id="anothersimplebeanTarget" class="org.sample.spring.AnotherSimpleBean" singleton="false"> <property name="value"> <value>foobar</value> </property> </bean> <bean id="debugInterceptor" class="org.springframework.aop.interceptor.DebugInterceptor"/> <bean id="simplebean" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="target"><ref bean="simplebeanTarget"/></property> <property name="proxyTargetClass"><value>true</value></property> <property name="interceptorNames"> <list> <value>debugInterceptor</value> </list> </property> </bean> <bean id="anothersimplebean" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="target"><ref bean="anothersimplebeanTarget"/></property> <property name="proxyTargetClass"><value>true</value></property> <property name="interceptorNames"> <list> <value>debugInterceptor</value> </list> </property> </bean> </beans>


Reply With Quote
