com.mockrunner.struts
Class DefaultExceptionHandlerConfig

java.lang.Object
  extended by com.mockrunner.struts.DefaultExceptionHandlerConfig
All Implemented Interfaces:
ExceptionHandlerConfig

public class DefaultExceptionHandlerConfig
extends java.lang.Object
implements ExceptionHandlerConfig

The default implementation of ExceptionHandlerConfig. It uses the Struts exception handling mechanism. Use the various constructors to provide your subclass of ExceptionHandler or to configure exception handling using an instance of ExceptionConfig. The ExceptionConfig class allows you to set the handler class an exception type. Use ActionTestModule.addExceptionHandler(com.mockrunner.struts.ExceptionHandlerConfig) to register an exception handler.


Constructor Summary
DefaultExceptionHandlerConfig(java.lang.Class exceptionClass)
           
DefaultExceptionHandlerConfig(org.apache.struts.config.ExceptionConfig exceptionConfig)
           
DefaultExceptionHandlerConfig(org.apache.struts.action.ExceptionHandler exceptionHandler, java.lang.Class exceptionClass)
           
DefaultExceptionHandlerConfig(org.apache.struts.action.ExceptionHandler exceptionHandler, org.apache.struts.config.ExceptionConfig exceptionConfig)
           
 
Method Summary
 boolean canHandle(java.lang.Exception exception)
          Returns if this handler is able to handle the exception.
 org.apache.struts.config.ExceptionConfig getExceptionConfig()
          Get the underlying ExceptionConfig.
 org.apache.struts.action.ExceptionHandler getExceptionHandler()
          Get the underlying ExceptionHandler.
 java.lang.Object handle(java.lang.Exception exception, org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handles the exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultExceptionHandlerConfig

public DefaultExceptionHandlerConfig(org.apache.struts.config.ExceptionConfig exceptionConfig)

DefaultExceptionHandlerConfig

public DefaultExceptionHandlerConfig(org.apache.struts.action.ExceptionHandler exceptionHandler,
                                     org.apache.struts.config.ExceptionConfig exceptionConfig)

DefaultExceptionHandlerConfig

public DefaultExceptionHandlerConfig(org.apache.struts.action.ExceptionHandler exceptionHandler,
                                     java.lang.Class exceptionClass)

DefaultExceptionHandlerConfig

public DefaultExceptionHandlerConfig(java.lang.Class exceptionClass)
Method Detail

canHandle

public boolean canHandle(java.lang.Exception exception)
Description copied from interface: ExceptionHandlerConfig
Returns if this handler is able to handle the exception.

Specified by:
canHandle in interface ExceptionHandlerConfig
Returns:
true if this handler is able to handle the exception, false otherwise

handle

public java.lang.Object handle(java.lang.Exception exception,
                               org.apache.struts.action.ActionMapping mapping,
                               org.apache.struts.action.ActionForm form,
                               javax.servlet.http.HttpServletRequest request,
                               javax.servlet.http.HttpServletResponse response)
                        throws javax.servlet.ServletException
Description copied from interface: ExceptionHandlerConfig
Handles the exception.

Specified by:
handle in interface ExceptionHandlerConfig
Parameters:
exception - the exception
mapping - the current ActionMapping
form - the current ActionForm
request - the current request
response - the current response
Returns:
the handler return value, usually an ActionForward, but may be any object
Throws:
javax.servlet.ServletException

getExceptionConfig

public org.apache.struts.config.ExceptionConfig getExceptionConfig()
Get the underlying ExceptionConfig. If you did not provide an instance of ExceptionConfig, this class will create one internally.

Returns:
the ExceptionConfig

getExceptionHandler

public org.apache.struts.action.ExceptionHandler getExceptionHandler()
Get the underlying ExceptionHandler.

Returns:
the ExceptionHandler