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

pack-priv Class InvocableHelper

extends Object
Class Inheritance
Imports
java.lang.reflect.Method, java.util.LinkedHashMap, .List, .Map, java.util.concurrent.ConcurrentHashMap, java.util.function.Function, org.apache.commons.logging.Log, .LogFactory, reactor.core.publisher.Mono, org.springframework.core.MethodParameter, .ReactiveAdapterRegistry, org.springframework.lang.Nullable, org.springframework.messaging.Message, org.springframework.messaging.handler.HandlerMethod, .MessagingAdviceBean, org.springframework.messaging.handler.invocation.AbstractExceptionHandlerMethodResolver, org.springframework.util.Assert

Help to initialize and invoke an InvocableHandlerMethod, and to then apply return value handling and exception handling. Holds all necessary configuration necessary to do so.
Author
Rossen Stoyanchev
Since
5.2

Field Summary

Modifier and TypeField and Description
private final HandlerMethodArgumentResolverComposite
private final Map<MessagingAdviceBean, AbstractExceptionHandlerMethodResolver>
private final Map<Class<?>, AbstractExceptionHandlerMethodResolver>
private final Function<Class<?>, AbstractExceptionHandlerMethodResolver>
private static final Log
private ReactiveAdapterRegistry
private final HandlerMethodReturnValueHandlerComposite

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addArgumentResolvers(List<? extends HandlerMethodArgumentResolver> resolvers)

Add the arguments resolvers to use for message handling and exception handling methods.

public void
addReturnValueHandlers(List<? extends HandlerMethodReturnValueHandler> handlers)

Add the return value handlers to use for message handling and exception handling methods.

public HandlerMethodArgumentResolverComposite
getArgumentResolvers()

Return the configured resolvers.

public ReactiveAdapterRegistry
getReactiveAdapterRegistry()

Return the configured registry for adapting reactive types.

public Mono<Void>
handleMessage(HandlerMethod handlerMethod, Message<?> message)

private Mono<Void>
handleReturnValue(Object returnValue, HandlerMethod handlerMethod, Message<?> message)

public InvocableHandlerMethod

Returns:

a method to handle the exception, or null
initExceptionHandlerMethod
(HandlerMethod
the method where the exception was raised
handlerMethod
,
Throwable
the exception raised or signaled
ex
)

Find an exception handling method for the given exception.

public InvocableHandlerMethod

Returns:

the created instance
initMessageMappingMethod
(HandlerMethod
the target handler method to invoke
handlerMethod
)

Create InvocableHandlerMethod with the configured arg resolvers.

public void
registerExceptionHandlerAdvice(MessagingAdviceBean bean, AbstractExceptionHandlerMethodResolver resolver)

Method to populate the MessagingAdviceBean cache (e.g. to support "global" @MessageExceptionHandler).

public void
setReactiveAdapterRegistry(ReactiveAdapterRegistry registry)

Configure the registry for adapting various reactive types.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

argumentResolversback to summary
private final HandlerMethodArgumentResolverComposite argumentResolvers
exceptionHandlerAdviceCacheback to summary
private final Map<MessagingAdviceBean, AbstractExceptionHandlerMethodResolver> exceptionHandlerAdviceCache
exceptionHandlerCacheback to summary
private final Map<Class<?>, AbstractExceptionHandlerMethodResolver> exceptionHandlerCache
exceptionMethodResolverFactoryback to summary
private final Function<Class<?>, AbstractExceptionHandlerMethodResolver> exceptionMethodResolverFactory
loggerback to summary
private static final Log logger
reactiveAdapterRegistryback to summary
private ReactiveAdapterRegistry reactiveAdapterRegistry
returnValueHandlersback to summary
private final HandlerMethodReturnValueHandlerComposite returnValueHandlers

Constructor Detail

InvocableHelperback to summary
public InvocableHelper(Function<Class<?>, AbstractExceptionHandlerMethodResolver> exceptionMethodResolverFactory)

Method Detail

addArgumentResolversback to summary
public void addArgumentResolvers(List<? extends HandlerMethodArgumentResolver> resolvers)

Add the arguments resolvers to use for message handling and exception handling methods.

addReturnValueHandlersback to summary
public void addReturnValueHandlers(List<? extends HandlerMethodReturnValueHandler> handlers)

Add the return value handlers to use for message handling and exception handling methods.

getArgumentResolversback to summary
public HandlerMethodArgumentResolverComposite getArgumentResolvers()

Return the configured resolvers.

Since
5.2.2
getReactiveAdapterRegistryback to summary
public ReactiveAdapterRegistry getReactiveAdapterRegistry()

Return the configured registry for adapting reactive types.

handleMessageback to summary
public Mono<Void> handleMessage(HandlerMethod handlerMethod, Message<?> message)
handleReturnValueback to summary
private Mono<Void> handleReturnValue(Object returnValue, HandlerMethod handlerMethod, Message<?> message)
initExceptionHandlerMethodback to summary
public InvocableHandlerMethod initExceptionHandlerMethod(HandlerMethod handlerMethod, Throwable ex)

Find an exception handling 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 handling methods registered via registerExceptionHandlerAdvice.

Parameters
handlerMethod:HandlerMethod

the method where the exception was raised

ex:Throwable

the exception raised or signaled

Returns:InvocableHandlerMethod

a method to handle the exception, or null

Annotations
@Nullable
initMessageMappingMethodback to summary
public InvocableHandlerMethod initMessageMappingMethod(HandlerMethod handlerMethod)

Create InvocableHandlerMethod with the configured arg resolvers.

Parameters
handlerMethod:HandlerMethod

the target handler method to invoke

Returns:InvocableHandlerMethod

the created instance

registerExceptionHandlerAdviceback to summary
public void registerExceptionHandlerAdvice(MessagingAdviceBean bean, AbstractExceptionHandlerMethodResolver resolver)

Method to populate the MessagingAdviceBean cache (e.g. to support "global" @MessageExceptionHandler).

setReactiveAdapterRegistryback to summary
public void setReactiveAdapterRegistry(ReactiveAdapterRegistry registry)

Configure the registry for adapting various reactive types.

By default this is an instance of ReactiveAdapterRegistry with default settings.