org.springframework.messaging.handler.invocation

Class AbstractExceptionHandlerMethodResolver

  • java.lang.Object
    • org.springframework.messaging.handler.invocation.AbstractExceptionHandlerMethodResolver
  • Direct Known Subclasses:
    AnnotationExceptionHandlerMethodResolver


    public abstract class AbstractExceptionHandlerMethodResolver
    extends java.lang.Object
    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.
    Since:
    4.0
    Author:
    Rossen Stoyanchev, Juergen Hoeller
    • Constructor Summary

      Constructors 
      Modifier Constructor and Description
      protected AbstractExceptionHandlerMethodResolver(java.util.Map<java.lang.Class<? extends java.lang.Throwable>,java.lang.reflect.Method> mappedMethods)
      Protected constructor accepting exception-to-method mappings.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      protected static java.util.List<java.lang.Class<? extends java.lang.Throwable>> getExceptionsFromMethodSignature(java.lang.reflect.Method method)
      Extract the exceptions this method handles.This implementation looks for sub-classes of Throwable in the method signature.
      boolean hasExceptionMappings()
      Whether the contained type has any exception mappings.
      java.lang.reflect.Method resolveMethod(java.lang.Exception exception)
      Find a Method to handle the given exception.
      java.lang.reflect.Method resolveMethodByExceptionType(java.lang.Class<? extends java.lang.Throwable> exceptionType)
      Find a Method to handle the given exception type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractExceptionHandlerMethodResolver

        protected AbstractExceptionHandlerMethodResolver(java.util.Map<java.lang.Class<? extends java.lang.Throwable>,java.lang.reflect.Method> mappedMethods)
        Protected constructor accepting exception-to-method mappings.
    • Method Detail

      • getExceptionsFromMethodSignature

        protected static java.util.List<java.lang.Class<? extends java.lang.Throwable>> getExceptionsFromMethodSignature(java.lang.reflect.Method method)
        Extract the exceptions this method handles.This implementation looks for sub-classes of Throwable in the method signature. The method is static to ensure safe use from sub-class constructors.
      • hasExceptionMappings

        public boolean hasExceptionMappings()
        Whether the contained type has any exception mappings.
      • resolveMethod

        @Nullable
        public java.lang.reflect.Method resolveMethod(java.lang.Exception exception)
        Find a Method to handle the given exception. Use ExceptionDepthComparator if more than one match is found.
        Parameters:
        exception - the exception
        Returns:
        a Method to handle the exception, or null if none found
      • resolveMethodByExceptionType

        @Nullable
        public java.lang.reflect.Method resolveMethodByExceptionType(java.lang.Class<? extends java.lang.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).
        Parameters:
        exceptionType - the exception type
        Returns:
        a Method to handle the exception, or null if none found
        Since:
        4.3.1