View Javadoc

1   package com.atlassian.xwork.results;
2   
3   import com.opensymphony.webwork.dispatcher.VelocityResult;
4   import com.opensymphony.xwork.ActionInvocation;
5   import com.opensymphony.xwork.util.OgnlValueStack;
6   import com.atlassian.util.profiling.UtilTimerStack;
7   import org.apache.velocity.Template;
8   import org.apache.velocity.app.VelocityEngine;
9   
10  /**
11   * A subclass of VelocityResult which adds profiling to execution and template retrieval.
12   */
13  public class ProfiledVelocityResult extends VelocityResult
14  {
15      public void doExecute(String finalLocation, ActionInvocation invocation) throws Exception
16      {
17          UtilTimerStack.push("XW View: doExecute(" + finalLocation + ")");
18  
19          try
20          {
21              super.doExecute(finalLocation, invocation);
22          }
23          finally
24          {
25              UtilTimerStack.pop("XW View: doExecute(" + finalLocation + ")");
26          }
27      }
28  
29      protected Template getTemplate(OgnlValueStack stack, VelocityEngine velocity, ActionInvocation invocation, String location) throws Exception
30      {
31          UtilTimerStack.push("XW View: getTemplate(" + location + ")");
32          try
33          {
34              return super.getTemplate(stack, velocity, invocation, location);
35          }
36          finally
37          {
38              UtilTimerStack.pop("XW View: getTemplate(" + location + ")");
39          }
40      }
41  }