-
Oct 1st, 2007, 04:01 AM
#1
ProxyBeanFactory doesn't work
Hi all,
I am new to AOP. I try to implement an example for AOP as a web application (JDK 5, Spring 2.0.6) in two cases:
1) Using the "BeanNameAutoProxyCreator" class
2) Using the "ProxyFactoryBean" class
In both cases I use the same advice "logInterceptor" which writes log messages before and after the invocation of every methods in the bean "priceIncreaseForm". Here are the two XML configs of the two cases:
1) with "BeanNameAutoProxyCreator":
<code>
...
<bean id="logInteceptor" class="interceptor.LoggingInterceptor"></bean>
<bean id="proxyCreator" class="org.springframework.aop.framework.autoproxy .BeanNameAutoProxyCreator">
<property name="beanNames"><value>priceIncreaseForm</value></property>
<property name="interceptorNames">
<list>
<value>logInteceptor</value>
</list>
</property>
</bean>
...
</code>
2) with "ProxyFactoryBean":
<code>
...
<bean id="proxyCreator" class="org.springframework.aop.framework.ProxyFact oryBean">
<property name="target">
<ref bean="priceIncreaseForm"/>
</property>
<property name="interceptorNames">
<list>
<value>logInteceptor</value>
</list>
</property>
</bean>
...
</code>
The weird thing is that it works in the first case but in the later case it doesn't! It doesn't run either though I've tried to enable autoproxy:
<code><aop:aspectj-autoproxy proxy-target-class="true"/></code>
(the bean "priceIncreaseForm" is a class, not interface)
Or have I associated the advice (logInterceptor) with a pointcut.
I don't know what is the root cause of this, and need your help. Any idea would be appreciated.
-
Oct 3rd, 2007, 05:42 AM
#2
When testing, you use "proxyCreator" bean and not "priceIncreaseForm", right ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules