• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Advice PointCut methods not being called?

 
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Finally i got it solved.



[Removed not nice comment. Mark Spritzler]
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Montana has cold dark nights. Perfect for the heat from incandescent light. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic