public class AnnotationEventHandlerAdapter extends Object implements EventMessageHandler
EventHandler
annotated methods into an EventMessageHandler
.EventMessageHandler
Constructor and Description |
---|
AnnotationEventHandlerAdapter(Object annotatedEventListener)
Wraps the given
annotatedEventListener , allowing it to be subscribed to an Event Bus. |
AnnotationEventHandlerAdapter(Object annotatedEventListener,
ParameterResolverFactory parameterResolverFactory)
Wraps the given
annotatedEventListener , allowing it to be subscribed to an Event Bus. |
AnnotationEventHandlerAdapter(Object annotatedEventListener,
ParameterResolverFactory parameterResolverFactory,
HandlerDefinition handlerDefinition)
Wraps the given
annotatedEventListener , allowing it to be subscribed to an Event Bus. |
Modifier and Type | Method and Description |
---|---|
boolean |
canHandle(EventMessage<?> event)
Indicates whether this handler can handle the given message
|
boolean |
canHandleType(Class<?> payloadType)
Indicates whether this handler can handle messages of given type
|
Class<?> |
getTargetType()
Returns the instance type that this handler delegates to.
|
Object |
handle(EventMessage<?> event)
Process the given event.
|
void |
prepareReset()
Performs any activities that are required to reset the state managed by handlers assigned to this handler.
|
<R> void |
prepareReset(R resetContext)
Performs any activities that are required to reset the state managed by handlers assigned to this handler.
|
boolean |
supportsReset()
Indicates whether the handlers managed by this invoker support a reset.
|
public AnnotationEventHandlerAdapter(Object annotatedEventListener)
annotatedEventListener
, allowing it to be subscribed to an Event Bus.annotatedEventListener
- the annotated event listenerpublic AnnotationEventHandlerAdapter(Object annotatedEventListener, ParameterResolverFactory parameterResolverFactory)
annotatedEventListener
, allowing it to be subscribed to an Event Bus. The given parameterResolverFactory
is used to resolve parameter values for handler methods.annotatedEventListener
- the annotated event listenerparameterResolverFactory
- the strategy for resolving handler method parameter valuespublic AnnotationEventHandlerAdapter(Object annotatedEventListener, ParameterResolverFactory parameterResolverFactory, HandlerDefinition handlerDefinition)
annotatedEventListener
, allowing it to be subscribed to an Event Bus. The given parameterResolverFactory
is used to resolve parameter values for handler methods. Handler definition is used to
create concrete handlers.annotatedEventListener
- the annotated event listenerparameterResolverFactory
- the strategy for resolving handler method parameter valueshandlerDefinition
- the handler definition used to create concrete handlerspublic Object handle(EventMessage<?> event) throws Exception
EventMessageHandler
handle
in interface EventMessageHandler
handle
in interface MessageHandler<EventMessage<?>>
event
- the event to handleException
- when an exception is raised during event handlingpublic boolean canHandle(EventMessage<?> event)
MessageHandler
canHandle
in interface MessageHandler<EventMessage<?>>
event
- The message to verifytrue
if this handler can handle the message, otherwise false
public boolean canHandleType(Class<?> payloadType)
MessageHandler
canHandleType
in interface MessageHandler<EventMessage<?>>
payloadType
- The payloadType to verifytrue
if this handler can handle the payloadType, otherwise false
public Class<?> getTargetType()
MessageHandler
getTargetType
in interface MessageHandler<EventMessage<?>>
public void prepareReset()
EventMessageHandler
prepareReset
in interface EventMessageHandler
public <R> void prepareReset(R resetContext)
EventMessageHandler
prepareReset
in interface EventMessageHandler
R
- the type of the provided resetContext
resetContext
- a R
used to support the reset operationpublic boolean supportsReset()
EventMessageHandler
supportsReset
in interface EventMessageHandler
true
if a reset is supported, otherwise false
Copyright © 2010–2023. All rights reserved.