|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mentawai.filter.ExceptionFilter
public class ExceptionFilter
A filter for handling exceptions that may occour during the action's execution. The filter catchs all the exceptions throwed by the action and call the method handleException. The default implementation of the handleException method put in the action's output the following attributes:
"message" - The message of the Exception (e.getMessage())
"stacktrace" - The Exception's stacktrace (e.getStackTrace())
"stackheader" - The Exception's first stacktrace (e.getStackTrace()[0])
Also, the method e.printStackTrace() is called if the attribute "trace" is setted to true.
After that, the filter return "exception" as the action's result. A Consequence must be mapped for this result.
The behavior of this filter can be changed by extending it's class and overriding the handleException method.
| Field Summary | |
|---|---|
static String |
EXCEPTION
Attribute EXCEPTION of ExceptionFilter. |
static String |
EXCEPTION_KEY
Attribute EXCEPTION_KEY of ExceptionFilter. |
static String |
MESSAGE_KEY
Attribute MESSAGE_KEY of ExceptionFilter. |
static String |
STACK_HEADER_KEY
Attribute STACK_HEADER_KEY of ExceptionFilter. |
static String |
STACK_TRACE_KEY
Attribute STACK_TRACE_KEY of ExceptionFilter. |
| Constructor Summary | |
|---|---|
ExceptionFilter()
Default constructor. |
|
ExceptionFilter(boolean trace)
Parametric constructor. |
|
| Method Summary | |
|---|---|
void |
destroy()
Gives a chance to the filter to deallocalte any resources before it is destroyed. |
String |
filter(InvocationChain chain)
Execute the chain and cacth any exception that occours, delegating to the handleException() method the resposability to handle the exception throwed by the chain's execution. |
protected static Throwable |
getRootCause(Throwable throwable)
Gets the root cause of exception. |
protected String |
handleException(Action a,
Throwable throwable)
Handle the exception, putting in the action's output the message of the exception, all the StackTrace elements and the first StackTrace element. |
protected String |
prepareForHtml(String s)
|
protected String |
prepareStackTrace(StackTraceElement[] stacktrace)
|
protected String |
prepareStackTrace(String[] stacktrace)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static String MESSAGE_KEY
public static String EXCEPTION_KEY
public static String STACK_TRACE_KEY
public static String STACK_HEADER_KEY
public static String EXCEPTION
| Constructor Detail |
|---|
public ExceptionFilter()
public ExceptionFilter(boolean trace)
trace - boolean| Method Detail |
|---|
public String filter(InvocationChain chain)
throws Exception
filter in interface Filterchain - The InvocationChain for the action this filter is being applied to.
Exceptionprotected static Throwable getRootCause(Throwable throwable)
throwable - Throwable
protected String handleException(Action a,
Throwable throwable)
a - the action that has throwed the exception.throwable - the exception throwed by the action's execution.
protected String prepareStackTrace(String[] stacktrace)
protected String prepareStackTrace(StackTraceElement[] stacktrace)
protected String prepareForHtml(String s)
public void destroy()
destroy in interface Filter
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||