Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JSF and the fly likes Accessing action method name from PhaseListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Accessing action method name from PhaseListener" Watch "Accessing action method name from PhaseListener" New topic
Author

Accessing action method name from PhaseListener

Preet Dholabhai
Greenhorn

Joined: Jan 24, 2010
Posts: 19
is there a way i could print action method name? i have this logs in each phase for the time it takes for them to complete, but it would be nice to get the action method name also along with the time.


Thanks & regards,
Preet
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15956
    
  19

I don't think that information is directly available. However, most popular logging systems have some sort of option to log timestamps on entry and exit from a method. Or, if you're really ambitious, you could instrument the action methods using AOP. In my case, that would be relatively easy, since I like to prefix the action method names with "do", but your mileage may vary.


Customer surveys are for companies who didn't pay proper attention to begin with.
Preet Dholabhai
Greenhorn

Joined: Jan 24, 2010
Posts: 19
Thanks for the reply Tim.

Yes, the logging system do facilitate by appending the method name but if I am not writing any loggers in a particular method then it won't show anything.

When you say instrument the action methods using AOP, what i understand is as follows:

get an entry in the web.xml for referring the SpringContext.xml.
declare bean definition for the managed bean and refer them using the ids in the jsf.
but here also, how do i get the action method name?

it just clicked me while writing my understanding above, is it by any chance possible to get it using java reflection?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15956
    
  19

I really doubt there's anything you can do in a purely JSF mode to get these metrics, short of customizing the source code that fires the action methods. Although, come to think of it, there MAY be pre-/post- logging code in JSF you can turn on.

Overall, though, you're probably better off using a code profiling tool.

And of course, if you're attempting to optimize before the fact, the old rule applies that you should never optimize until a need is demonstrated. Frequently it will cost you more resources than the "optimization" saves you over the life of the system.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing action method name from PhaseListener
 
Similar Threads
how to hide the struts2 action name being displayed in the URL
Validation Problem
Dispatch Action name is coming null in the action class
problem in configuring interceptor in struts.xml
Unexpected error when running application from tomcat.