@ComponentProfile(summary="Interceptor that adds Logging Context at the start of a workflow, removes it at the end", tag="interceptor") public class LoggingContextWorkflowInterceptor extends WorkflowInterceptorImpl
org.slf4j.MDC#put(String, String)
.
An alternative to this interceptor might be AddLoggingContext
and RemoveLoggingContext
as part of the
service execution chain.
AddLoggingContext
,
RemoveLoggingContext
In the adapter configuration file this class is aliased as logging-context-workflow-interceptor which is the preferred alternative to the fully qualified classname when building your configuration.
WorkflowInterceptorImpl.WorkflowInterceptorException
log
Constructor and Description |
---|
LoggingContextWorkflowInterceptor() |
LoggingContextWorkflowInterceptor(java.lang.String uid) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the component.
|
java.lang.Boolean |
getAddDefaultKeysAsObjectMetadata()
Return whether the default keys will be added to object metadata.
|
java.lang.String |
getKey()
Deprecated.
|
java.lang.Boolean |
getUseDefaultKeys()
Return whether the default keys will be populated
|
java.lang.String |
getValue()
Deprecated.
|
KeyValuePairList |
getValuesToSet() |
void |
init()
Initialises the component.
|
void |
processingStart(AdaptrisMessage inputMsg)
Mark the start of processing a message.
|
void |
setAddDefaultKeysAsObjectMetadata(java.lang.Boolean addDefaultKeysAsObjectMetadata) |
void |
setKey(java.lang.String key)
Deprecated.
|
void |
setUseDefaultKeys(java.lang.Boolean useDefaultKeys)
Sets whether to write channel, workflow and message id into the Mapped Diagnostic Context.
|
void |
setValue(java.lang.String val)
Deprecated.
|
void |
setValuesToSet(KeyValuePairList values)
Set the list of values to set
|
void |
start()
Starts the component.
|
void |
stop()
Stop the component
|
void |
workflowEnd(AdaptrisMessage inputMsg,
AdaptrisMessage outputMsg)
Mark the end of a workflow.
|
void |
workflowStart(AdaptrisMessage inputMsg)
Mark the start of a workflow.
|
changeState, getUniqueId, parentChannel, parentWorkflow, prepare, registerParentChannel, registerParentWorkflow, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setUniqueId, wasSuccessful
public LoggingContextWorkflowInterceptor()
public LoggingContextWorkflowInterceptor(java.lang.String uid)
public void workflowStart(AdaptrisMessage inputMsg)
WorkflowInterceptor
inputMsg
- the message that will be processed by this workflow.public void processingStart(AdaptrisMessage inputMsg)
WorkflowInterceptor
#workflowStart
public void workflowEnd(AdaptrisMessage inputMsg, AdaptrisMessage outputMsg)
WorkflowInterceptor
inputMsg
- the original message that was originally submitted to the workflow; in the event of an exception during
processing, the exception will be stored in object metadata in the inputMsgoutputMsg
- the message contaning any changes that may have been applied by the services within the workflow.CoreConstants.OBJ_METADATA_EXCEPTION
public void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
CoreException
- wrapping any underlying Exception
spublic void start() throws CoreException
ComponentLifecycle
Once a component is started it should be ready to process messages. In the case of AdaptrisMessageConsumer
, calling start
will begin message delivery.
CoreException
- wrapping any underlying Exception
spublic void stop()
ComponentLifecycle
A stopped component is not expected to be ready to process messages. In the case of AdaptrisMessageConsumer
, calling stop
will pause message delivery. Throwing a RuntimeException
may cause unintended consequences
public void close()
ComponentLifecycle
A closed component should release any connections it uses, etc. and clean up completely. Throwing a RuntimeException
may
cause unintended consequences
@Deprecated public java.lang.String getKey()
@Deprecated public void setKey(java.lang.String key)
If not specified then we will try to use one of the following values in order of preference provided they are not null/blank
key
- the contextKey to set.@Deprecated public java.lang.String getValue()
@Deprecated public void setValue(java.lang.String val)
If not specified then we will try to use one of the following values in order of preference provided they are not null/blank
val
- the contextValue to setpublic KeyValuePairList getValuesToSet()
public void setValuesToSet(KeyValuePairList values)
values
- the mapping to addpublic void setUseDefaultKeys(java.lang.Boolean useDefaultKeys)
Sets whether to write channel, workflow and message id into the Mapped Diagnostic Context. The following keys will be added for each message:
useDefaultKeys
- whether to populate the Mapped Diagnostic Contextpublic java.lang.Boolean getUseDefaultKeys()
Return whether the default keys will be populated
public void setAddDefaultKeysAsObjectMetadata(java.lang.Boolean addDefaultKeysAsObjectMetadata)
public java.lang.Boolean getAddDefaultKeysAsObjectMetadata()
Return whether the default keys will be added to object metadata.