Class 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 Detail

      • DEFAULT_PRIORITY

        public static long DEFAULT_PRIORITY
        The default priority.
      • DEFAULT_PRIORITY_ON_RESOLUTION_FAILURE

        public static long DEFAULT_PRIORITY_ON_RESOLUTION_FAILURE
        The default priority in case of resolution failure.
    • Constructor Detail

      • DefaultPriorityProvider

        public DefaultPriorityProvider()
    • 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 value
        execution - the execution entity
        errorMessageHeading - 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 interface PriorityProvider<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 on
        jobDefinitionId - 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 execution
        param - the generic param
        jobDefinitionId - 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 execution
        param - 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 priority
        propertyKey - the key which identifies the property
        execution - the current execution
        errorMsgHead - 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 entity
        value - the current value
        e - 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