Package org.camunda.bpm.engine.impl
Class DefaultPriorityProvider<T>
- java.lang.Object
-
- org.camunda.bpm.engine.impl.DefaultPriorityProvider<T>
-
- Type Parameters:
T
- the type of the param to determine the priority
- All Implemented Interfaces:
PriorityProvider<T>
- Direct Known Subclasses:
DefaultExternalTaskPriorityProvider
,DefaultJobPriorityProvider
public abstract class DefaultPriorityProvider<T> extends java.lang.Object implements PriorityProvider<T>
Represents a default priority provider, which contains some functionality to evaluate the priority. Can be used as base class for other priority providers. *- Author:
- Christopher Zell
-
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_PRIORITY
The default priority.static long
DEFAULT_PRIORITY_ON_RESOLUTION_FAILURE
The default priority in case of resolution failure.
-
Constructor Summary
Constructors Constructor Description DefaultPriorityProvider()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description long
determinePriority(ExecutionEntity execution, T param, java.lang.String jobDefinitionId)
protected java.lang.Long
evaluateValueProvider(ParameterValueProvider valueProvider, ExecutionEntity execution, java.lang.String errorMessageHeading)
Evaluates a given value provider with the given execution entity to determine the correct value.long
getDefaultPriority()
Returns the default priority.long
getDefaultPriorityOnResolutionFailure()
Returns the default priority in case of resolution failure.protected java.lang.Long
getProcessDefinedPriority(ProcessDefinitionImpl processDefinition, java.lang.String propertyKey, ExecutionEntity execution, java.lang.String errorMsgHead)
Returns the priority which is defined in the given process definition.protected abstract java.lang.Long
getProcessDefinitionPriority(ExecutionEntity execution, T param)
Returns the priority defined in the process definition.protected abstract java.lang.Long
getSpecificPriority(ExecutionEntity execution, T param, java.lang.String jobDefinitionId)
Returns the priority defined in the specific entity.protected boolean
isSymptomOfContextSwitchFailure(java.lang.Throwable t, ExecutionEntity contextExecution)
protected boolean
isValidLongValue(java.lang.Number value)
Checks if the given number is a valid long value.protected abstract void
logNotDeterminingPriority(ExecutionEntity execution, java.lang.Object value, ProcessEngineException e)
Logs the exception which was thrown if the priority can not be determined.
-
-
-
Method Detail
-
getDefaultPriority
public long getDefaultPriority()
Returns the default priority.- Returns:
- the default priority
-
getDefaultPriorityOnResolutionFailure
public long getDefaultPriorityOnResolutionFailure()
Returns the default priority in case of resolution failure.- Returns:
- the default priority
-
evaluateValueProvider
protected java.lang.Long evaluateValueProvider(ParameterValueProvider valueProvider, ExecutionEntity execution, java.lang.String errorMessageHeading)
Evaluates a given value provider with the given execution entity to determine the correct value. The error message heading is used for the error message if the validation fails because the value is no valid priority.- Parameters:
valueProvider
- the provider which contains the valueexecution
- the execution entityerrorMessageHeading
- the heading which is used for the error message- Returns:
- the valid priority value
-
determinePriority
public long determinePriority(ExecutionEntity execution, T param, java.lang.String jobDefinitionId)
- Specified by:
determinePriority
in interfacePriorityProvider<T>
- Parameters:
execution
- may be null when the job is not created in the context of a running process instance (e.g. a timer start event)param
- extra parameter to determine priority onjobDefinitionId
- the job definition id if related to a job- Returns:
- the determined priority
-
getSpecificPriority
protected abstract java.lang.Long getSpecificPriority(ExecutionEntity execution, T param, java.lang.String jobDefinitionId)
Returns the priority defined in the specific entity. Like a job definition priority or an activity priority. The result can also be null in that case the process priority will be used.- Parameters:
execution
- the current executionparam
- the generic paramjobDefinitionId
- the job definition id if related to a job- Returns:
- the specific priority
-
getProcessDefinitionPriority
protected abstract java.lang.Long getProcessDefinitionPriority(ExecutionEntity execution, T param)
Returns the priority defined in the process definition. Can also be null in that case the fallback is the default priority.- Parameters:
execution
- the current executionparam
- the generic param- Returns:
- the priority defined in the process definition
-
getProcessDefinedPriority
protected java.lang.Long getProcessDefinedPriority(ProcessDefinitionImpl processDefinition, java.lang.String propertyKey, ExecutionEntity execution, java.lang.String errorMsgHead)
Returns the priority which is defined in the given process definition. The priority value is identified with the given propertyKey. Returns null if the process definition is null or no priority was defined.- Parameters:
processDefinition
- the process definition that should contains the prioritypropertyKey
- the key which identifies the propertyexecution
- the current executionerrorMsgHead
- the error message header which is used if the evaluation fails- Returns:
- the priority defined in the given process
-
logNotDeterminingPriority
protected abstract void logNotDeterminingPriority(ExecutionEntity execution, java.lang.Object value, ProcessEngineException e)
Logs the exception which was thrown if the priority can not be determined.- Parameters:
execution
- the current execution entityvalue
- the current valuee
- the exception which was catched
-
isSymptomOfContextSwitchFailure
protected boolean isSymptomOfContextSwitchFailure(java.lang.Throwable t, ExecutionEntity contextExecution)
-
isValidLongValue
protected boolean isValidLongValue(java.lang.Number value)
Checks if the given number is a valid long value.- Parameters:
value
- the number which should be checked- Returns:
- true if is a valid long value, false otherwise
-
-