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

Accessing action method name from PhaseListener

 
Preet Dholabhai
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Tim Holloway
Saloon Keeper
Posts: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Preet Dholabhai
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic