• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Methods on advice are not being called

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am new to spring and I am using spring in action 2.0.

I am at chapter 4 trying "creating classic Spring aspects".

I have done everything given in the book but I found that at runtime when I call the perform method it does not first calls the

method on the advice.

I am puting all the code here.



And the rest of the classes are as they are in the book.

i am only keeping the AudienceAdvie class


Please help.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Try to remove the extra space in the performancePointcut's pattern :


2. What kind of proxy are you using to apply your advices ? I can't see any definition of it.
 
rakesh kadulkar
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have tried that as well. ".*perform" but still it does not work.

Well the part till where I read in the book there is no description about proxy yet . May be it will come later on.

But I thought it will work as the book was giving different approaches to apply advice to pointcuts.

So may be it will come later on in the chapter but since I stuck up there itself I didnt went further.

As you said is proxy mandatory?



 
rakesh kadulkar
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now as I have read further I found that proxy is required and my example is working fine.

Now I have one doubt that is my AudienceAdvice is implementing ThrowsAdvice interface as well and the apt method.

But from the method which is specified in the pointcut when I thow an exception ( throw new Exception()) the program still ends

calling afterReturning() where as it should call afterThrowing().

I am not getting why this is happening.

 
rakesh kadulkar
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is my modified XML file

 
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
I recommend also reading some more up to date material on Spring, as Spring is on version 3.0 and version 2.5 came out a couple/few years ago. The approach in the book you are reading is the old way of doing things. Today, they are much more simpler, where your Aspect class is now a POJO, not implementing any interfaces, so that you have clean code, and no tight coupling with Spring.

Spring in Action for Spring 3.0 is in the works, but you can sign up for the MEAP program and start learning today.

Good Luck

Mark
 
rakesh kadulkar
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The training company where I work they have started training for spring recently and I am the only person who is upgrading on this technology. The company gives training for spring 2.5 so i have to upgrade myself on spring 2.5.

If I upgrade on it. so later on if I start learing Spring 3.0 I can easily compare between two versions of the spring and I can explain the difference and advantages in best way.

Anyways thaks for the concern.

 
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

rakesh kankavlikar wrote:The training company where I work they have started training for spring recently and I am the only person who is upgrading on this technology. The company gives training for spring 2.5 so i have to upgrade myself on spring 2.5.

If I upgrade on it. so later on if I start learing Spring 3.0 I can easily compare between two versions of the spring and I can explain the difference and advantages in best way.

Anyways thaks for the concern.



Sure, no problem there, but my point is still valid. You should read material that covers 2.5 well and doesn't teach you the old way of doing things.

So in SPring 2.5 they added the aop namespace to make AOP so much easier. They also added Annotations for doing AOP too, if you prefer Annotations over xml.

Using <bean> tags to set up AOP is way too much typing and the old approach.

Mark

 
rakesh kadulkar
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Will do that.

Thank you.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic