Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

AOP does not works!

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying may hands on AOP.

and this is what my simple XML metadata looks like.


I have defined the aspect and the point cut expression. But I guess I am missing something coz my after and before advice functions never get called.

I am not using ApplicationContext in my main program to execute this simply creating the bean for which aspect has been advised.

Is there something extra that needs to be done?



 
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
I don't know how Worker#execute even compiles...
 
Christophe Verré
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

I am not using ApplicationContext in my main program to execute this simply creating the bean for which aspect has been advised.


How are you creating the com.Worker bean ?
 
samarthya saurabh
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Christophe Verré wrote:I don't know how Worker#execute even compiles...



Is there any syntactical issue here? My code compiles fine. I do include all the imports.... or am i missing something?
 
samarthya saurabh
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Christophe Verré wrote:
How are you creating the com.Worker bean ?



Using the new operator to create the object of Worker class and calling execute of the function.
 
Christophe Verré
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
This is not going to work. If Spring is not managing your bean, how is it going to apply AOP ? Declare your worker in your context file, and get your bean via the application context or via a bean factory.

Is there any syntactical issue here? My code compiles fine. I do include all the imports.... or am i missing something?


A method returning a boolean must return something. Your code doesn't return anything.
 
samarthya saurabh
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Christophe Verré wrote:This is not going to work. If Spring is not managing your bean, how is it going to apply AOP ? Declare your worker in your context file, and get your bean via the application context or via a bean factory.



Thanks! I will try to do it that way!!


A method returning a boolean must return something. Your code doesn't return anything.



Yep!! i agree i removed the logic of the function, just to avoid un-necessary bloating and forgot the return.

Thank you!
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic