public class AuditingInterceptor extends Object implements CommandHandlerInterceptor
AuditDataProvider
is attached to each of these events
just before the Unit Of Work is committed. After the Unit Of Work has been committed, an optional AuditLogger
may write an entry to the audit logs.
Note that this class requires a Unit Of Work to be available. This means that you should always configure a Unit Of
Work interceptor before the AuditingInterceptor. Failure to do so will result in an AxonConfigurationException
.
The auditing interceptor can only attach meta data to event whose Message.getMetaData()
methods returns an instance of MetaData
, which is the default behavior
for any event implementation provided by Axon.Constructor and Description |
---|
AuditingInterceptor() |
Modifier and Type | Method and Description |
---|---|
Object |
handle(CommandMessage<?> command,
UnitOfWork unitOfWork,
InterceptorChain chain)
The handle method is invoked each time a command is dispatched through the command bus that the
CommandHandlerInterceptor is declared on.
|
void |
setAuditDataProvider(AuditDataProvider auditDataProvider)
Sets the AuditingDataProvider for this interceptor.
|
void |
setAuditLogger(AuditLogger auditLogger)
Sets the logger that writes events to the audit logs.
|
public Object handle(CommandMessage<?> command, UnitOfWork unitOfWork, InterceptorChain chain) throws Throwable
CommandHandlerInterceptor
unitOfWork
.
The interceptor is responsible for the continuation of the dispatch process by invoking the InterceptorChain.proceed(CommandMessage)
method on the given
interceptorChain
.
Any information gathered by interceptors may be attached to the unitOfWork. This information is made
available to the CommandCallback provided by the dispatching component.
Interceptors are highly recommended not to change the type of the command handling result, as the dispatching
component might expect a result of a specific type.handle
in interface CommandHandlerInterceptor
command
- The command being dispatchedunitOfWork
- The UnitOfWork in whichchain
- The interceptor chain that allows this interceptor to proceed the dispatch processThrowable
- any exception that occurs while handling the commandpublic void setAuditDataProvider(AuditDataProvider auditDataProvider)
EmptyDataProvider
, which provides no
correlation information.auditDataProvider
- the instance providing the auditing information to attach to the events.public void setAuditLogger(AuditLogger auditLogger)
NullAuditLogger
, which does nothing.auditLogger
- the logger that writes events to the audit logsCopyright © 2010-2014. All Rights Reserved.