org.apache.struts2.interceptor.debugging
Class DebuggingInterceptor

java.lang.Object
  extended by org.apache.struts2.interceptor.debugging.DebuggingInterceptor
All Implemented Interfaces:
Interceptor, Serializable

public class DebuggingInterceptor
extends Object
implements Interceptor

Provides several different debugging screens to provide insight into the data behind the page. The value of the 'debug' request parameter determines the screen:

Example: http://localhost:8080/Welcome.action?debug=xml

This interceptor only is activated when devMode is enabled in struts.properties. The 'debug' parameter is removed from the parameter list before the action is executed. All operations occur before the natural Result has a chance to execute.

See Also:
Serialized Form

Field Summary
private  String[] _ignoreKeys
           
private static String COMMAND_MODE
           
private static String CONSOLE_MODE
           
private  boolean consoleEnabled
           
private static String DEBUG_PARAM
           
private  boolean devMode
           
private  boolean enableXmlWithConsole
           
private static String EXPRESSION_PARAM
           
private  FreemarkerManager freemarkerManager
           
private  HashSet<String> ignoreKeys
           
private  String[] ignorePrefixes
           
private static Log log
           
private static long serialVersionUID
           
private static String SESSION_KEY
           
private static String XML_MODE
           
 
Constructor Summary
DebuggingInterceptor()
           
 
Method Summary
 void destroy()
          Unused.
private  String getParameter(String key)
          Gets a single string from the request parameters
 void init()
          Unused.
 String intercept(ActionInvocation inv)
          Allows the Interceptor to do some processing on the request before and/or after the rest of the processing of the request by the ActionInvocation or to short-circuit the processing and just return a String return code.
protected  void printContext()
          Prints the current context to the response in XML format.
protected  void printContext(PrettyPrintWriter writer)
          Prints the current request to the existing writer.
protected  void serializeIt(Object bean, String name, PrettyPrintWriter writer, List<Object> stack)
          Recursive function to serialize objects to XML.
 void setDevMode(String mode)
           
 void setEnableXmlWithConsole(boolean enableXmlWithConsole)
           
 void setFreemarkerManager(FreemarkerManager mgr)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

log

private static final Log log

ignorePrefixes

private String[] ignorePrefixes

_ignoreKeys

private String[] _ignoreKeys

ignoreKeys

private HashSet<String> ignoreKeys

XML_MODE

private static final String XML_MODE
See Also:
Constant Field Values

CONSOLE_MODE

private static final String CONSOLE_MODE
See Also:
Constant Field Values

COMMAND_MODE

private static final String COMMAND_MODE
See Also:
Constant Field Values

SESSION_KEY

private static final String SESSION_KEY
See Also:
Constant Field Values

DEBUG_PARAM

private static final String DEBUG_PARAM
See Also:
Constant Field Values

EXPRESSION_PARAM

private static final String EXPRESSION_PARAM
See Also:
Constant Field Values

enableXmlWithConsole

private boolean enableXmlWithConsole

devMode

private boolean devMode

freemarkerManager

private FreemarkerManager freemarkerManager

consoleEnabled

private boolean consoleEnabled
Constructor Detail

DebuggingInterceptor

public DebuggingInterceptor()
Method Detail

setDevMode

public void setDevMode(String mode)

setFreemarkerManager

public void setFreemarkerManager(FreemarkerManager mgr)

init

public void init()
Unused.

Specified by:
init in interface Interceptor

destroy

public void destroy()
Unused.

Specified by:
destroy in interface Interceptor

intercept

public String intercept(ActionInvocation inv)
                 throws Exception
Description copied from interface: Interceptor
Allows the Interceptor to do some processing on the request before and/or after the rest of the processing of the request by the ActionInvocation or to short-circuit the processing and just return a String return code.

Specified by:
intercept in interface Interceptor
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().

getParameter

private String getParameter(String key)
Gets a single string from the request parameters

Parameters:
key - The key
Returns:
The parameter value

printContext

protected void printContext()
Prints the current context to the response in XML format.


printContext

protected void printContext(PrettyPrintWriter writer)
Prints the current request to the existing writer.

Parameters:
writer - The XML writer

serializeIt

protected void serializeIt(Object bean,
                           String name,
                           PrettyPrintWriter writer,
                           List<Object> stack)
Recursive function to serialize objects to XML. Currently it will serialize Collections, maps, Arrays, and JavaBeans. It maintains a stack of objects serialized already in the current functioncall. This is used to avoid looping (stack overflow) of circular linked objects. Struts and XWork objects are ignored.

Parameters:
bean - The object you want serialized.
name - The name of the object, used for element <name/>
writer - The XML writer
stack - List of objects we're serializing since the first calling of this function (to prevent looping on circular references).

setEnableXmlWithConsole

public void setEnableXmlWithConsole(boolean enableXmlWithConsole)
Parameters:
enableXmlWithConsole - the enableXmlWithConsole to set


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.