aspose file tools*
The moose likes Spring and the fly likes AOP does not works! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
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: 14687
    
  16

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


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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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: 14687
    
  16

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://aspose.com/file-tools
 
subject: AOP does not works!