|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.opensymphony.xwork.interceptor.ExceptionMappingInterceptor
public class ExceptionMappingInterceptor
This interceptor forms the core functionality of the exception handling feature. Exception handling allows you to map
an exception to a result code, just as if the action returned a result code instead of throwing an unexpected
exception. When an exception is encountered, it is wrapped with an ExceptionHolder and pushed on the stack,
providing easy access to the exception from within your result.
Note: While you can configure exception mapping in your configuration file at any point, the configuration
will not have any effect if this interceptor is not in the interceptor stack for your actions. It is recommended that
you make this interceptor the first interceptor on the stack, ensuring that it has full access to catch any
exception, even those caused by other interceptors.
publishException(com.opensymphony.xwork.ActionInvocation, ExceptionHolder). The default implementation
pushes the given ExceptionHolder on value stack. A custom implementation could add additional logging etc.
Example code:
<xwork>
<include file="webwork-default.xml"/>
<package name="default" extends="webwork-default">
<global-results>
<result name="success" type="freemarker">error.ftl</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error"/>
</global-exception-mappings>
<action name="test">
<interceptor-ref name="exception"/>
<interceptor-ref name="basicStack"/>
<exception-mapping exception="com.acme.CustomException" result="custom_error"/>
<result name="custom_error">custom_error.ftl</result>
<result name="success" type="freemarker">test.ftl</result>
</action>
</package>
</xwork>
| Field Summary | |
|---|---|
protected org.apache.commons.logging.Log |
log
|
| Constructor Summary | |
|---|---|
ExceptionMappingInterceptor()
|
|
| Method Summary | |
|---|---|
void |
destroy()
Called to let an interceptor clean up any resources it has allocated. |
int |
getDepth(String exceptionMapping,
Throwable t)
Return the depth to the superclass matching. |
void |
init()
Called after an interceptor is created, but before any requests are processed using intercept , giving
the Interceptor a chance to initialize any needed resources. |
String |
intercept(ActionInvocation invocation)
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 |
publishException(ActionInvocation invocation,
ExceptionHolder exceptionHolder)
Default implementation to handle ExceptionHolder publishing. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected org.apache.commons.logging.Log log
| Constructor Detail |
|---|
public ExceptionMappingInterceptor()
| Method Detail |
|---|
public void destroy()
Interceptor
destroy in interface Interceptorpublic void init()
Interceptorintercept , giving
the Interceptor a chance to initialize any needed resources.
init in interface Interceptor
public String intercept(ActionInvocation invocation)
throws Exception
InterceptorActionInvocation or to short-circuit the processing and just return a String return code.
intercept in interface InterceptorActionInvocation.invoke(), or from the interceptor itself.
Exception - any system-level error, as defined in Action.execute().
public int getDepth(String exceptionMapping,
Throwable t)
protected void publishException(ActionInvocation invocation,
ExceptionHolder exceptionHolder)
invocation - The invocation to publish Exception for.exceptionHolder - The exceptionHolder wrapping the Exception to publish.
|
XWork Project Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||