• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Advice PointCut methods not being called?

 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>




 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finally i got it solved.



[Removed not nice comment. Mark Spritzler]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic