com.opensymphony.xwork2.interceptor

## Class TimerInterceptor

- java.lang.Object
- - com.opensymphony.xwork2.interceptor.AbstractInterceptor
  - - com.opensymphony.xwork2.interceptor.TimerInterceptor

- All Implemented Interfaces:
    Interceptor, Serializable

  Deprecated.
  will be dropped with next major release (2.6)

      @Deprecated
      public class TimerInterceptor
      extends AbstractInterceptor

  This interceptor logs the amount of time in milliseconds. In order for this interceptor to work properly, the logging framework must be set to at least the `INFO` level. This interceptor relies on the Commons Logging API to report its execution-time value.
  - logLevel (optional) - what log level should we use (`trace, debug, info, warn, error, fatal`)? - defaut is `info`
  - logCategory (optional) - If provided we would use this category (eg. `com.mycompany.app`). Default is to use `com.opensymphony.xwork2.interceptor.TimerInterceptor`.
  The parameters above enables us to log all action execution times in our own logfile. This interceptor can be extended to provide custom message format. Users should override the `invokeUnderTiming` method.

       <!-- records only the action's execution time -->
       <action name="someAction" class="com.examples.SomeAction">
           <interceptor-ref name="completeStack"/>
           <interceptor-ref name="timer"/>
           <result name="success">good_result.ftl</result>
       </action>

       <!-- records action's execution time as well as other interceptors-->
       <action name="someAction" class="com.examples.SomeAction">
           <interceptor-ref name="timer"/>
           <interceptor-ref name="completeStack"/>
           <result name="success">good_result.ftl</result>
       </action>

  This second example uses our own log category at debug level.

       <!-- records only the action's execution time -->
       <action name="someAction" class="com.examples.SomeAction">
           <interceptor-ref name="completeStack"/>
           <interceptor-ref name="timer">
               <param name="logLevel">debug</param>
               <param name="logCategory">com.mycompany.myapp.actiontime</param>
           <interceptor-ref/>
           <result name="success">good_result.ftl</result>
       </action>

       <!-- records action's execution time as well as other interceptors-->
       <action name="someAction" class="com.examples.SomeAction">
           <interceptor-ref name="timer"/>
           <interceptor-ref name="completeStack"/>
           <result name="success">good_result.ftl</result>
       </action>

  Author:
    Jason Carreira, Claus Ibsen
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected org.apache.logging.log4j.Logger` | `categoryLogger` Deprecated.
    `protected String` | `logCategory` Deprecated.
    `protected String` | `logLevel` Deprecated.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TimerInterceptor()` Deprecated.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `doLog(org.apache.logging.log4j.Logger logger, String message)` Deprecated. Performs the actual logging.
    `String` | `getLogCategory()` Deprecated.
    `protected org.apache.logging.log4j.Logger` | `getLoggerToUse()` Deprecated. Get's the logger to use.
    `String` | `getLogLevel()` Deprecated.
    `String` | `intercept(ActionInvocation invocation)` Deprecated. Override to handle interception
    `protected String` | `invokeUnderTiming(ActionInvocation invocation)` Deprecated. Is called to invoke the action invocation and time the execution time.
    `void` | `setLogCategory(String logCatgory)` Deprecated.
    `void` | `setLogLevel(String logLevel)` Deprecated.
    `protected boolean` | `shouldLog()` Deprecated. Determines if we should log the time.

    - ### Methods inherited from class com.opensymphony.xwork2.interceptor.AbstractInterceptor

      `destroy, init`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### categoryLogger

          protected org.apache.logging.log4j.Logger categoryLogger

      Deprecated.

    - #### logCategory

          protected String logCategory

      Deprecated.

    - #### logLevel

          protected String logLevel

      Deprecated.

  - ### Constructor Detail

    - #### TimerInterceptor

          public TimerInterceptor()

      Deprecated.

  - ### Method Detail

    - #### getLogCategory

          public String getLogCategory()

      Deprecated.

    - #### setLogCategory

          public void setLogCategory(String logCatgory)

      Deprecated.

    - #### getLogLevel

          public String getLogLevel()

      Deprecated.

    - #### setLogLevel

          public void setLogLevel(String logLevel)

      Deprecated.

    - #### intercept

          public String intercept(ActionInvocation invocation)
                           throws Exception

      Deprecated.
      Description copied from class: `AbstractInterceptor`
      Override to handle interception
      Specified by:
        `intercept` in interface `Interceptor`
      Specified by:
        `intercept` in class `AbstractInterceptor`
      Parameters:
        `invocation` - the action invocation
      Returns:
        the return code, either returned from `ActionInvocation.invoke()`, or from the interceptor itself.
      Throws:
        `Exception` - any system-level error, as defined in `Action.execute()`.

    - #### invokeUnderTiming

          protected String invokeUnderTiming(ActionInvocation invocation)
                                      throws Exception

      Deprecated.
      Is called to invoke the action invocation and time the execution time.
      Parameters:
        `invocation` - the action invocation.
      Returns:
        the result of the action execution.
      Throws:
        `Exception` - can be thrown from the action.

    - #### shouldLog

          protected boolean shouldLog()

      Deprecated.
      Determines if we should log the time.
      Returns:
        true to log, false to not log.

    - #### getLoggerToUse

          protected org.apache.logging.log4j.Logger getLoggerToUse()

      Deprecated.
      Get's the logger to use.
      Returns:
        the logger to use.

    - #### doLog

          protected void doLog(org.apache.logging.log4j.Logger logger,
                               String message)

      Deprecated.
      Performs the actual logging.
      Parameters:
        `logger` - the provided logger to use.
        `message` - the message to log.

Copyright © 2000–2023 Apache Software Foundation. All rights reserved.