Advanced customizations
Parameter Resolvers
You can configure additional ParameterResolver
s by extending the ParameterResolverFactory
class and creating a file named /META-INF/service/org.axonframework.common.annotation.ParameterResolverFactory
containing the fully qualified name of the implementing class.
Caution
At this moment, OSGi support is limited to the fact that the required headers are mentioned in the manifest file. The automatic detection of
ParameterResolverFactory
instances works in OSGi, but due to classloader limitations, it might be necessary to copy the contents of the/META-INF/service/org.axonframework.common.annotation.ParameterResolverFactory
file to the OSGi bundle containing the classes to resolve parameters for (i.e. the event handler).
Meta Annotations
TODO
Customizing Message Handler behavior
HanderEnhancers
It is possible to wrap handlers with custom logic. This differs from HandlerInterceptors in that you have access to the Aggregate member at the time of resolving. You can use HandlerEnhancers to intercept and perform checks on groups of @CommandHandler
s or @EventHandler
s.
To create a HandlerEnhancer you start by implementing HandlerEnhancerDefinition
and overriding the wrapHandler()
method. All this method does is give you access to the MessageHandlingMember<T>
which is an object representing any handler that is specified in the system.
You can then sort these handlers based on their annotations by using the annotationAttributes(Annotation annotation)
method. This will filter out only those handlers that use that Annotation
.
For your HandlerEnhancer to run you'll need to create a META-INF/services/org.axonframework.messaging.annotation.HandlerEnhancerDefinition
file containing the fully qualified name of the handler enhancer you would like to use.
Example:
Implement the
HandlerEnhancerDefinition
interfaceOverride the
wrapHandler
method to perform your own logic.Sort out the types of messages you want to handle, for example any
CommandHandler
s or your own custom annotation even.Handle the method inside of a
MessageHandlingMember
If you would like to skip handling just return the original that was passed into the
wrapHandler
method.
To skip all handling of the handler then just throw an exception.
Last updated