This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Action Class - Logging timing

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a quick and easy way to log timing for the execute method of the action class? I want to keep track of how long the execute method took to complete. I extended the process() method of the RequestProcessor and kept track of how long the processActionPerform() method took to complete. However, I am not comfortable with having to modify native struts code in the process() method. Is there another less invasive way to implement log timing?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One possible way to do this would be to write a base Action class that extends Action, and then have all your Action classes extend your base Action class. You could then implement your logging in the base Action class.
 
Leonard Murro
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the base action class - Would I extend on any particular method or would I need to create a new method? How could I get access to the before and after time of the execute method?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are many ways to do this, but one way would be to definie an abstract method named something other than execute (e.g. myExecute) that your subclasses must implement. Then call this method from your base Action class's execute method. You could then get the begin time before calling myExecute and the end time after myExecute returns. This would also give you an opportunity to do whatever other tasks you want every Action to perform, such as checking security roles, checking for valid session, etc.
[ April 10, 2006: Message edited by: Merrill Higginson ]
 
My first bit of advice is that if you are going to be a mime, you shouldn't talk. Even the tiny ad is nodding:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!