File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Advice PointCut methods not being called? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Advice PointCut methods not being called?" Watch "Advice PointCut methods not being called?" New topic
Author

Advice PointCut methods not being called?

Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 844
I have no idea, why AudienceAdvice joinpoint methods are not being called.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="kenny" class="Instrumentalist">
<property name="instrument" ref="instrument"></property>
</bean>
<bean id="instrument" class="Saxophone"></bean>

<bean id="audience" class="Audience"></bean>
<bean id="audienceadvice" class="AudienceAdvice">
<property name="audience" ref="audience"></property>
</bean>

<bean id="audiencearoundadvice" class="AudienceAroundAdvice">
<property name="audience" ref="audience"></property>
</bean>

<bean id="performancePointCut" class="org.springframework.aop.support.JdkRegexpMethodPointcut">
<property name="pattern" value=".*"></property>
</bean>

<bean id="audienceAdvisor" class="org.springframework.aop.support.DefaultPointcutAdvisor">
<property name="advice" ref="audienceadvice"></property>
<property name="pointcut" ref="performancePointCut"></property>
</bean>

<bean id="audienceAdvisor1" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice" ref="audienceadvice"></property>
<property name="pattern" value=".*perform"></property>
</bean>
</beans>





SCJP 1.4, SCWCD 5, SCBCD 5, OCPJWSD 5,SCEA-1, Started Assignment Part 2
My blog- http://rkydesigns.blogspot.com
Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 844
Finally i got it solved.



[Removed not nice comment. Mark Spritzler]
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

FYI, it looks like you are testing out the code from the Spring in Action book. And to let you know that that book is based mostly on Spring 2.0 version. While a lot of that book is still relevant, some of the examples are "older" way of doing things.

For instance in your Advice class, you are now tied to Spring because of the interfaces that you implemented. Where the more POJO clean way is to create a class and add either xml aop tags to declare your joinpoints or with Annotations. This keeps your "Aspect" class a pure Java object.

Here is the xml way
http://static.springsource.org/spring/docs/2.5.x/reference/aop.html#aop-schema-declaring-an-aspect

And here is the Annotation way
http://static.springsource.org/spring/docs/2.5.x/reference/aop.html#aop-at-aspectj

Good Luck

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Advice PointCut methods not being called?
 
Similar Threads
spring AOP doesn't work
unable to call AOP method
AOP not getting invoked on my Target Bean Method --> Singer.perform() method
Spring AOP aspect not working.
Methods on advice are not being called