dune
Mar 17th, 2005, 04:41 PM
Is it possible to apply an advice (MethodInterceptor) to a static method? Specifically, I have the following applicationContext.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="testTarget" class="foo.Test"/>
<bean id="testService" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target">
<ref local="testTarget"/>
</property>
<property name="proxyTargetClass">
<value>true</value>
</property>
<property name="interceptorNames">
<list>
<value>testAdvisor</value>
</list>
</property>
</bean>
<bean id="testAdvisor" class="org.springframework.aop.support.RegexpMethodPointc utAdvisor">
<property name="advice">
<ref local="testAdvice"/>
</property>
<property name="pattern">
<value>.*</value>
</property>
</bean>
<bean id="testAdvice" class="foo.TestAdvice"/>
</beans>
foo.Test has one static and one non-static method. The advice is applied on the non-static method when it's run. Any thoughts?
Thanks,
Dave
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="testTarget" class="foo.Test"/>
<bean id="testService" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target">
<ref local="testTarget"/>
</property>
<property name="proxyTargetClass">
<value>true</value>
</property>
<property name="interceptorNames">
<list>
<value>testAdvisor</value>
</list>
</property>
</bean>
<bean id="testAdvisor" class="org.springframework.aop.support.RegexpMethodPointc utAdvisor">
<property name="advice">
<ref local="testAdvice"/>
</property>
<property name="pattern">
<value>.*</value>
</property>
</bean>
<bean id="testAdvice" class="foo.TestAdvice"/>
</beans>
foo.Test has one static and one non-static method. The advice is applied on the non-static method when it's run. Any thoughts?
Thanks,
Dave