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.
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?
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.
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?
posted 13 years ago
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 ]