-
Nov 15th, 2007, 09:47 AM
#1
Simple AOP Question
Hello;
I am simply trying to do some AOP on a particular object and on a particular method of that object. I can get the before() advice to work for every method on my object, but I just want to get it to work for just one execute() method. I am sure there is a way to do this but I cannot figure this out based on my spring configuration. Here is my configuration
<bean id="batchProcessMain"
class="org.springframework.aop.framework.ProxyFact oryBean">
<property name="target" ref="batchProcessMainTarget"/>
<property name="interceptorNames">
<list>
<value>batchEventTrackerInterceptor</value>
</list>
</property>
</bean>
<bean id="batchProcessMainTarget"
class="com.putnam.fams.batch.BatchProcessMain">
</bean>
<bean id="batchEventTrackerInterceptor"
class="com.putnam.fams.batch.aop.BatchEventTracker Interceptor">
<property name="eventTrackerDao" ref="eventTrackerDao"/>
</bean>
Here is my Advice class
public class BatchEventTrackerInterceptor
implements MethodBeforeAdvice, AfterReturningAdvice, ThrowsAdvice {
/**
*
*/
public void before(Method arg0, Object[] arg1, Object arg2) throws Throwable {
if( "execute".equals( arg0.getName() ) ) {
log.info(" This is the execute() Method Process" );
}
}
In my BatchEventTrackerInterceptor I can determine the method easy enough, but I would like to configure this outside of my code.
Can someone please point out what I am doing wrong?
Thanks
Peter
I determined the problem. I needed to add the following to my spring config to get the execute to work;
<bean id="batchEventTrackerAdvisor"
class="org.springframework.aop.support.RegexpMetho dPointcutAdvisor">
<property name="advice">
<ref local="batchEventTrackerInterceptor"/>
</property>
<property name="pattern">
<value>execute</value>
</property>
</bean>
Last edited by pdelaney; Nov 15th, 2007 at 11:25 AM.
Reason: Determined the solution
-
Nov 15th, 2007, 09:52 AM
#2
Use a RegExpMethodAdvisor around your advice OR use the aop config to define an AspectJ pointcut which matches your needs.
-
Nov 15th, 2007, 11:26 AM
#3
AOP problme
Thanks found the problem thanks for the help!!
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