Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AOP does not works!

 
samarthya saurabh
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • 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?



 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know how Worker#execute even compiles...
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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 Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic