Top Description Fields Constructors Methods
org.springframework.messaging.handler.invocation

public abstract Class AbstractExceptionHandlerMethodResolver

extends Object
Class Inheritance
Known Direct Subclasses
org.springframework.messaging.handler.annotation.support.AnnotationExceptionHandlerMethodResolver
Imports
java.lang.reflect.Method, java.util.ArrayList, .HashMap, .List, .Map, org.springframework.core.ExceptionDepthComparator, org.springframework.lang.Nullable, org.springframework.util.Assert, .ConcurrentReferenceHashMap

Cache exception handling method mappings and provide options to look up a method that should handle an exception. If multiple methods match, they are sorted using ExceptionDepthComparator and the top match is returned.
Authors
Rossen Stoyanchev, Juergen Hoeller, Sam Brannen
Since
4.0

Field Summary

Modifier and TypeField and Description
private final Map<Class<? extends Throwable>, Method>
private final Map<Class<? extends Throwable>, Method>
private static final Method

Constructor Summary

AccessConstructor and Description
protected
AbstractExceptionHandlerMethodResolver(Map<Class<? extends Throwable>, Method> mappedMethods)

Protected constructor accepting exception-to-method mappings.

Method Summary

Modifier and TypeMethod and Description
protected static List<Class<? extends Throwable>>
getExceptionsFromMethodSignature(Method method)

Extract the exceptions this method handles.

private Method
getMappedMethod(Class<? extends Throwable> exceptionType)

Return the Method mapped to the given exception type, or NO_MATCHING_EXCEPTION_HANDLER_METHOD if none.

public boolean
hasExceptionMappings()

Whether the contained type has any exception mappings.

private void
public Method

Returns:

a Method to handle the exception, or null if none found
resolveMethod
(Throwable
the exception
exception
)

Find a Method to handle the given exception.

public Method

Returns:

a Method to handle the exception, or null if none found
resolveMethodByExceptionType
(Class<? extends Throwable>
the exception type
exceptionType
)

Find a Method to handle the given exception type.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

exceptionLookupCacheback to summary
private final Map<Class<? extends Throwable>, Method> exceptionLookupCache
mappedMethodsback to summary
private final Map<Class<? extends Throwable>, Method> mappedMethods
NO_MATCHING_EXCEPTION_HANDLER_METHODback to summary
private static final Method NO_MATCHING_EXCEPTION_HANDLER_METHOD

Constructor Detail

AbstractExceptionHandlerMethodResolverback to summary
protected AbstractExceptionHandlerMethodResolver(Map<Class<? extends Throwable>, Method> mappedMethods)

Protected constructor accepting exception-to-method mappings.

Method Detail

getExceptionsFromMethodSignatureback to summary
protected static List<Class<? extends Throwable>> getExceptionsFromMethodSignature(Method method)

Extract the exceptions this method handles. This implementation looks for subclasses of Throwable in the method signature.

The method is static to ensure safe use from subclass constructors.

Annotations
@SuppressWarnings:unchecked
getMappedMethodback to summary
private Method getMappedMethod(Class<? extends Throwable> exceptionType)

Return the Method mapped to the given exception type, or NO_MATCHING_EXCEPTION_HANDLER_METHOD if none.

Annotations
@Nullable
hasExceptionMappingsback to summary
public boolean hasExceptionMappings()

Whether the contained type has any exception mappings.

noMatchingExceptionHandlerback to summary
private void noMatchingExceptionHandler()

For the NO_MATCHING_EXCEPTION_HANDLER_METHOD constant.

Annotations
@SuppressWarnings:unused
resolveMethodback to summary
public Method resolveMethod(Throwable exception)

Find a Method to handle the given exception.

Uses ExceptionDepthComparator if more than one match is found.

Parameters
exception:Throwable

the exception

Returns:Method

a Method to handle the exception, or null if none found

Annotations
@Nullable
resolveMethodByExceptionTypeback to summary
public Method resolveMethodByExceptionType(Class<? extends Throwable> exceptionType)

Find a Method to handle the given exception type. This can be useful if an Exception instance is not available (e.g. for tools).

Uses ExceptionDepthComparator if more than one match is found.

Parameters
exceptionType:Class<? extends Throwable>

the exception type

Returns:Method

a Method to handle the exception, or null if none found

Annotations
@Nullable
Since
4.3.1