I'm new to Spring, and tried to set up a BeanNameAutoProxyCreator example just to see the AOP stuff work, and I'm having some trouble.
My xml looks like this:
From the examples I've seen, I would've expected my before method on my AutoLoggerAdvice class to get called for any methods on my SampleSpringObject, but nothing seems to get called. I call the getters on my SampleSpringObject, and I don't see my before method get called.Code:<bean id="sampleSpringObject" class="com.agentscape.associate.test.SampleSpringObjectImpl"> <property name="name" value="Joe"/> <property name="age" value="28"/> </bean> <bean id="autoLogger" class="com.agentscape.associate.test.AutoLoggerAdvice"/> <bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> <property name="interceptorNames"> <value>autoLogger</value> </property> <property name="beanNames"> <value>*</value> </property> </bean>
My Advice class is very simple, just:
I know the advice and the bean work, because I was able to get an example working with this xml:Code:public class AutoLoggerAdvice implements MethodBeforeAdvice { public void before(Method method, Object[] args, Object target) throws Throwable { System.out.println("method.getName() = " + method.getName()); } }
Do I have something wrong in my BeanNameAutoProxyCreator config that it's not picking up the methods in my SampleSpringObject?Code:<bean id="sampleSpringObjectTarget" class="com.agentscape.associate.test.SampleSpringObjectImpl"> <property name="name" value="Joe"/> <property name="age" value="28"/> </bean> <bean id="autoLogger" class="com.agentscape.associate.test.AutoLoggerAdvice"/> <bean id="sampleSpringObject" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces"> <list> <value>com.agentscape.associate.test.SampleSpringObject</value> </list> </property> <property name="interceptorNames"> <list> <value>autoLogger</value> </list> </property> <property name="target"> <ref bean="sampleSpringObjectTarget"/> </property> </bean>
Thanks in advance.


Reply With Quote