List of usage examples for org.springframework.messaging.handler.invocation InvocableHandlerMethod InvocableHandlerMethod
public InvocableHandlerMethod(Object bean, Method method)
From source file:org.springframework.messaging.handler.invocation.AbstractMethodMessageHandler.java
/** * Find an {@code @MessageExceptionHandler} method for the given exception. * The default implementation searches methods in the class hierarchy of the * HandlerMethod first and if not found, it continues searching for additional * {@code @MessageExceptionHandler} methods among the configured * {@linkplain org.springframework.messaging.handler.MessagingAdviceBean * MessagingAdviceBean}, if any.//from w ww . j a va 2 s.co m * @param handlerMethod the method where the exception was raised * @param exception the raised exception * @return a method to handle the exception, or {@code null} * @since 4.2 */ @Nullable protected InvocableHandlerMethod getExceptionHandlerMethod(HandlerMethod handlerMethod, Exception exception) { if (logger.isDebugEnabled()) { logger.debug("Searching methods to handle " + exception.getClass().getSimpleName()); } Class<?> beanType = handlerMethod.getBeanType(); AbstractExceptionHandlerMethodResolver resolver = this.exceptionHandlerCache.get(beanType); if (resolver == null) { resolver = createExceptionHandlerMethodResolverFor(beanType); this.exceptionHandlerCache.put(beanType, resolver); } Method method = resolver.resolveMethod(exception); if (method != null) { return new InvocableHandlerMethod(handlerMethod.getBean(), method); } for (MessagingAdviceBean advice : this.exceptionHandlerAdviceCache.keySet()) { if (advice.isApplicableToBeanType(beanType)) { resolver = this.exceptionHandlerAdviceCache.get(advice); method = resolver.resolveMethod(exception); if (method != null) { return new InvocableHandlerMethod(advice.resolveBean(), method); } } } return null; }