|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.xwork2.interceptor.AbstractInterceptor
com.opensymphony.xwork2.interceptor.TimerInterceptor
public class TimerInterceptor
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.
trace, debug, info, warn, error, fatal
)? - defaut is info
com.mycompany.app
).
Default is to use com.opensymphony.xwork2.interceptor.TimerInterceptor
.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>
Field Summary | |
---|---|
protected org.apache.commons.logging.Log |
categoryLogger
|
protected static org.apache.commons.logging.Log |
log
|
protected java.lang.String |
logCategory
|
protected java.lang.String |
logLevel
|
Constructor Summary | |
---|---|
TimerInterceptor()
|
Method Summary | |
---|---|
protected void |
doLog(org.apache.commons.logging.Log logger,
java.lang.String message)
Performs the actual logging. |
java.lang.String |
getLogCategory()
|
protected org.apache.commons.logging.Log |
getLoggerToUse()
Get's the logger to use. |
java.lang.String |
getLogLevel()
|
java.lang.String |
intercept(ActionInvocation invocation)
Override to handle interception |
protected java.lang.String |
invokeUnderTiming(ActionInvocation invocation)
Is called to invoke the action invocation and time the execution time. |
void |
setLogCategory(java.lang.String logCatgory)
|
void |
setLogLevel(java.lang.String logLevel)
|
protected boolean |
shouldLog()
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 |
---|
protected static final org.apache.commons.logging.Log log
protected org.apache.commons.logging.Log categoryLogger
protected java.lang.String logCategory
protected java.lang.String logLevel
Constructor Detail |
---|
public TimerInterceptor()
Method Detail |
---|
public java.lang.String getLogCategory()
public void setLogCategory(java.lang.String logCatgory)
public java.lang.String getLogLevel()
public void setLogLevel(java.lang.String logLevel)
public java.lang.String intercept(ActionInvocation invocation) throws java.lang.Exception
AbstractInterceptor
intercept
in interface Interceptor
intercept
in class AbstractInterceptor
ActionInvocation.invoke()
, or from the interceptor itself.
java.lang.Exception
- any system-level error, as defined in Action.execute()
.protected java.lang.String invokeUnderTiming(ActionInvocation invocation) throws java.lang.Exception
invocation
- the action invocation.
java.lang.Exception
- can be thrown from the action.protected boolean shouldLog()
protected org.apache.commons.logging.Log getLoggerToUse()
protected void doLog(org.apache.commons.logging.Log logger, java.lang.String message)
logger
- the provided logger to use.message
- the message to log.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |