This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Spring and the fly likes AOP ambiguous situation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Spring
Bookmark "AOP ambiguous situation" Watch "AOP ambiguous situation" New topic
Author

AOP ambiguous situation

Shivaji Byrapaneni
Greenhorn

Joined: Oct 20, 2008
Posts: 22
Hello,

I had a scenario like i need to log the statements for method start and end of each and every public method.

I had opted for spring AOP as it suits my requirements best..


Now i had flow like this



I used CGLib for proxy. so i had added thsi statement to my beans-config.xml




Now the problem is i can see logs for Builders,Delgators and DAOs only.

is it due to Controllers implementing something and rest not ?

Could any body please help me how to overcome this...?

i need the log statements to be printed for all the layers...

Many thanks in advance
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Depends on your pointcut expression, and/or which xml file you have it in. So those classes you mentioned that it is working is in an ApplicationContext object, and the Controller's are loaded in a different context. so they aren't together. I am suspecting the applicationContext has your Aspects defined in them. Whereas the xml file that defines your Controller classes does not.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Shivaji Byrapaneni
Greenhorn

Joined: Oct 20, 2008
Posts: 22
No im using multi action form controller and it is the only controller that i had and i had imported all the other xmls using import statemnt on top

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Shivaji Byrapaneni wrote:No im using multi action form controller and it is the only controller that i had and i had imported all the other xmls using import statemnt on top



I didn't say a particular type of Controller, just Controller.

Anyway, in the Web, you have two different contexts. One for the web and a parent ApplicationContext. Your services are in the parent ApplicationContext as well as your AOP Aspects. The Controller is in the web AppContext. The controller can inject and get beans from the parent ApplicationContext, but not the other way around, so the AOP Aspects can't see or do anything with your Controller. The parent Application Context is created first, with its lifecycle. Then the Web context is created with your Controller created, way after the AOP proxies for your Aspect have been created.

Hope that helps clarify it for you.

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: AOP ambiguous situation