Class ProcessDataContext
- java.lang.Object
-
- org.camunda.bpm.engine.impl.interceptor.ProcessDataContext
-
public class ProcessDataContext extends 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 Map<String,ProcessDataContext.ProcessDataStack>
mdcDataStacks
All data stacks we need to keep for MDC loggingprotected String
mdcPropertyActivityId
protected String
mdcPropertyActivityName
protected String
mdcPropertyApplicationName
protected String
mdcPropertyBusinessKey
protected String
mdcPropertyDefinitionId
protected String
mdcPropertyDefinitionKey
protected String
mdcPropertyEngineName
protected String
mdcPropertyInstanceId
protected String
mdcPropertyTenantId
protected static 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(String value, String property)
protected void
addToStack(ProcessDataContext.ProcessDataStack stack, String value)
void
clearMdc()
Remove all logging context properties from the MDCString
getLatestActivityId()
protected boolean
hasNoMdcValues()
protected String
initProperty(Supplier<String> configSupplier)
protected static boolean
isNotBlank(String property)
protected static boolean
isNull(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(String val1, String val2)
-
-
-
Field Detail
-
NULL_VALUE
protected static final String NULL_VALUE
- See Also:
- Constant Field Values
-
mdcPropertyActivityId
protected String mdcPropertyActivityId
-
mdcPropertyActivityName
protected String mdcPropertyActivityName
-
mdcPropertyApplicationName
protected String mdcPropertyApplicationName
-
mdcPropertyBusinessKey
protected String mdcPropertyBusinessKey
-
mdcPropertyDefinitionId
protected String mdcPropertyDefinitionId
-
mdcPropertyDefinitionKey
protected String mdcPropertyDefinitionKey
-
mdcPropertyInstanceId
protected String mdcPropertyInstanceId
-
mdcPropertyTenantId
protected String mdcPropertyTenantId
-
mdcPropertyEngineName
protected String mdcPropertyEngineName
-
handleMdc
protected boolean handleMdc
-
activityIdStack
protected ProcessDataContext.ProcessDataStack activityIdStack
-
mdcDataStacks
protected Map<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 String getLatestActivityId()
- Returns:
- the latest value of the activity id property if exists,
null
otherwise
-
addToStack
protected void addToStack(ProcessDataContext.ProcessDataStack stack, String value)
-
isNotBlank
protected static boolean isNotBlank(String property)
-
isNull
protected static boolean isNull(String value)
-
-