public class SimpleEventHandlerInvoker extends Object implements EventHandlerInvoker
EventHandlerInvoker
that forwards events to a list of registered EventListeners
.Constructor and Description |
---|
SimpleEventHandlerInvoker(List<?> eventListeners,
ListenerInvocationErrorHandler listenerInvocationErrorHandler)
Initializes a
SimpleEventHandlerInvoker containing the given list of eventListeners . |
SimpleEventHandlerInvoker(List<?> eventListeners,
ParameterResolverFactory parameterResolverFactory,
ListenerInvocationErrorHandler listenerInvocationErrorHandler)
Initializes a
SimpleEventHandlerInvoker containing the given list of eventListeners . |
SimpleEventHandlerInvoker(Object... eventListeners)
Initializes a
SimpleEventHandlerInvoker containing one or more eventListeners . |
Modifier and Type | Method and Description |
---|---|
Object |
handle(EventMessage<?> message)
Handles the given
message . |
boolean |
hasHandler(EventMessage<?> eventMessage)
Check whether or not this invoker has handlers that can handle the given
eventMessage . |
public SimpleEventHandlerInvoker(Object... eventListeners)
SimpleEventHandlerInvoker
containing one or more eventListeners
. If an event
listener is assignable to EventListener
it will registered as is. If not, it will be wrapped by a new
AnnotationEventListenerAdapter
.
Events handled by the invoker will be passed to all the given eventListeners
. If an exception is
triggered during event handling it will be logged using a LoggingErrorHandler
but otherwise
ignored.
eventListeners
- one or more event listeners to register with this invokerpublic SimpleEventHandlerInvoker(List<?> eventListeners, ListenerInvocationErrorHandler listenerInvocationErrorHandler)
SimpleEventHandlerInvoker
containing the given list of eventListeners
. If an event
listener is assignable to EventListener
it will registered as is. If not, it will be wrapped by a new
AnnotationEventListenerAdapter
.
Events handled by the invoker will be passed to all the given eventListeners
. If an exception is
triggered during event handling it will be handled by the given listenerErrorHandler
.
eventListeners
- list of event listeners to register with this invokerlistenerInvocationErrorHandler
- error handler that handles exceptions during processingpublic SimpleEventHandlerInvoker(List<?> eventListeners, ParameterResolverFactory parameterResolverFactory, ListenerInvocationErrorHandler listenerInvocationErrorHandler)
SimpleEventHandlerInvoker
containing the given list of eventListeners
. If an event
listener is assignable to EventListener
it will registered as is. If not, it will be wrapped by a new
AnnotationEventListenerAdapter
.
Events handled by the invoker will be passed to all the given eventListeners
. If an exception is
triggered during event handling it will be handled by the given listenerErrorHandler
.
eventListeners
- list of event listeners to register with this invokerparameterResolverFactory
- The parameter resolver factory to resolve parameters of the Event Handler methods withlistenerInvocationErrorHandler
- error handler that handles exceptions during processingpublic Object handle(EventMessage<?> message) throws Exception
MessageHandler
message
.handle
in interface MessageHandler<EventMessage<?>>
message
- The message to be processed.Exception
- any exception that occurs during message handlingpublic boolean hasHandler(EventMessage<?> eventMessage)
EventHandlerInvoker
eventMessage
.hasHandler
in interface EventHandlerInvoker
eventMessage
- The message to be processedtrue
if the invoker has one or more handlers that can handle the given message, false
otherwiseCopyright © 2010–2017. All rights reserved.