Class ProcessDataContext
- java.lang.Object
-
- org.camunda.bpm.engine.impl.interceptor.ProcessDataContext
-
public class ProcessDataContext extends java.lang.Object
Holds the contextual process data.
New context properties are always part of a section that can be started bypushSection(ExecutionEntity)
. The section keeps track of all pushed properties. Those can easily be cleared by popping the section withpopSection()
afterwards, e.g. after the successful execution.
A property can be pushed to the logging context (MDC) if there is a configured non-empty context name for it in theprocess engine configuration
. The following configuration options are available:- loggingContextActivityId - the context property for the activity id
- loggingContextApplicationName - the context property for the application name
- loggingContextBusinessKey - the context property for the business key
- loggingContextDefinitionId - the context property for the definition id
- loggingContextProcessInstanceId - the context property for the instance id
- loggingContextTenantId - the context property for the tenant id
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ProcessDataContext.ProcessDataSections
protected static class
ProcessDataContext.ProcessDataStack
-
Field Summary
Fields Modifier and Type Field Description protected ProcessDataContext.ProcessDataStack
activityIdStack
protected boolean
handleMdc
protected java.util.Map<java.lang.String,ProcessDataContext.ProcessDataStack>
mdcDataStacks
All data stacks we need to keep for MDC loggingprotected java.lang.String
mdcPropertyActivityId
protected java.lang.String
mdcPropertyApplicationName
protected java.lang.String
mdcPropertyBusinessKey
protected java.lang.String
mdcPropertyDefinitionId
protected java.lang.String
mdcPropertyInstanceId
protected java.lang.String
mdcPropertyTenantId
protected static java.lang.String
NULL_VALUE
protected ProcessDataContext.ProcessDataSections
sections
-
Constructor Summary
Constructors Constructor Description ProcessDataContext(ProcessEngineConfigurationImpl configuration)
ProcessDataContext(ProcessEngineConfigurationImpl configuration, boolean initFromCurrentMdc)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addToStack(java.lang.String value, java.lang.String property)
protected void
addToStack(ProcessDataContext.ProcessDataStack stack, java.lang.String value)
void
clearMdc()
Remove all logging context properties from the MDCjava.lang.String
getLatestActivityId()
protected boolean
hasNoMdcValues()
protected static boolean
isNotBlank(java.lang.String property)
protected static boolean
isNull(java.lang.String value)
void
popSection()
Pop the latest section, remove all pushed properties of that section and - if logging context properties are defined - update the MDC accordingly.boolean
pushSection(ExecutionEntity execution)
Start a new section that keeps track of the pushed properties.void
updateMdcFromCurrentValues()
Update the MDC with the current values of this logging contextprotected static boolean
valuesEqual(java.lang.String val1, java.lang.String val2)
-
-
-
Field Detail
-
NULL_VALUE
protected static final java.lang.String NULL_VALUE
- See Also:
- Constant Field Values
-
mdcPropertyActivityId
protected java.lang.String mdcPropertyActivityId
-
mdcPropertyApplicationName
protected java.lang.String mdcPropertyApplicationName
-
mdcPropertyBusinessKey
protected java.lang.String mdcPropertyBusinessKey
-
mdcPropertyDefinitionId
protected java.lang.String mdcPropertyDefinitionId
-
mdcPropertyInstanceId
protected java.lang.String mdcPropertyInstanceId
-
mdcPropertyTenantId
protected java.lang.String mdcPropertyTenantId
-
handleMdc
protected boolean handleMdc
-
activityIdStack
protected ProcessDataContext.ProcessDataStack activityIdStack
-
mdcDataStacks
protected java.util.Map<java.lang.String,ProcessDataContext.ProcessDataStack> mdcDataStacks
All data stacks we need to keep for MDC logging
-
sections
protected ProcessDataContext.ProcessDataSections sections
-
-
Constructor Detail
-
ProcessDataContext
public ProcessDataContext(ProcessEngineConfigurationImpl configuration)
-
ProcessDataContext
public ProcessDataContext(ProcessEngineConfigurationImpl configuration, boolean initFromCurrentMdc)
-
-
Method Detail
-
pushSection
public boolean pushSection(ExecutionEntity execution)
Start a new section that keeps track of the pushed properties. If logging context properties are defined, the MDC is updated as well. This also includes clearing the MDC for the first section that is pushed for the logging context so that only the current properties will be present in the MDC (might be less than previously present in the MDC). The previous logging context needs to be reset in the MDC when this one is closed. This can be achieved by using#updateMdc(String)
with the previous logging context.- Parameters:
execution
- the execution to retrieve the context data from- Returns:
true
if the section contains any updates and therefore should be popped later bypopSection()
-
hasNoMdcValues
protected boolean hasNoMdcValues()
-
popSection
public void popSection()
Pop the latest section, remove all pushed properties of that section and - if logging context properties are defined - update the MDC accordingly.
-
clearMdc
public void clearMdc()
Remove all logging context properties from the MDC
-
updateMdcFromCurrentValues
public void updateMdcFromCurrentValues()
Update the MDC with the current values of this logging context
-
getLatestActivityId
public java.lang.String getLatestActivityId()
- Returns:
- the latest value of the activity id property if exists,
null
otherwise
-
addToStack
protected void addToStack(java.lang.String value, java.lang.String property)
-
addToStack
protected void addToStack(ProcessDataContext.ProcessDataStack stack, java.lang.String value)
-
isNotBlank
protected static boolean isNotBlank(java.lang.String property)
-
valuesEqual
protected static boolean valuesEqual(java.lang.String val1, java.lang.String val2)
-
isNull
protected static boolean isNull(java.lang.String value)
-
-