File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes AOP does not works! Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Spring
Reply Bookmark "AOP does not works!" Watch "AOP does not works!" New topic
Author

AOP does not works!

samarthya saurabh
Greenhorn

Joined: May 03, 2010
Posts: 17
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?





Samarthya
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14670
    
  11

I don't know how Worker#execute even compiles...


[My Blog]
All roads lead to JavaRanch
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14670
    
  11

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

Joined: May 03, 2010
Posts: 17
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

Joined: May 03, 2010
Posts: 17
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

Joined: Nov 24, 2005
Posts: 14670
    
  11

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

Joined: May 03, 2010
Posts: 17
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!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: AOP does not works!
 
Similar Threads
Spring AOP program not running as expected
Can AOP work with BeanFactory Resource Implementation ?
Simple AOP not working
aop and transations
Spring MVC AOP Logger