protected Method getExceptionHandlerMethod( FlowControllerHandlerContext context, String methodName, Throwable ex,
Object formBean )
{
FlowController flowController = context.getFlowController();
String cacheKey = methodName + '/' + ex.getClass().getName();
ClassLevelCache cache = ClassLevelCache.getCache( flowController.getClass() );
Method method = ( Method ) cache.get( CACHEID_EXCEPTION_HANDLER_METHODS, cacheKey );
if ( method != null )
{
return method;
}
Class flowControllerClass = flowController.getClass();
for ( Class exClass = ex.getClass(); exClass != null; exClass = exClass.getSuperclass() )
{
Class[] args = new Class[]{ exClass, String.class, String.class, Object.class };
Method foundMethod = InternalUtils.lookupMethod( flowControllerClass, methodName, args );
//
// If we didn't find an exception-handler with the right signature, look for the deprecated signature with
// FormData as the last argument.
//
if ( foundMethod == null && ( formBean == null || formBean instanceof FormData ) )
{
args = new Class[]{ exClass, String.class, String.class, FormData.class };
foundMethod = InternalUtils.lookupMethod( flowControllerClass, methodName, args );
}
//
// If we didn't find an exception-handler with the right signature, look for the deprecated signature with
// ActionForm as the last argument.
//
if ( foundMethod == null && ( formBean == null || formBean instanceof ActionForm ) )
{
args = new Class[]{ exClass, String.class, String.class, ActionForm.class };
foundMethod = InternalUtils.lookupMethod( flowControllerClass, methodName, args );
}
if ( foundMethod != null )
{
if ( _log.isDebugEnabled() )
{
_log.debug( "Found exception handler for " + exClass.getName() );
}
if ( ! Modifier.isPublic( foundMethod.getModifiers() ) ) foundMethod.setAccessible( true );
cache.put( CACHEID_EXCEPTION_HANDLER_METHODS, cacheKey, foundMethod );
return foundMethod;
}
else
{
if ( _log.isErrorEnabled() )