Interface VariableScope

  • All Known Subinterfaces:
    DelegateExecution, DelegateTask, ExecutionEntity, TaskEntity
    All Known Implementing Classes:
    ExecutionEntityImpl, NoExecutionVariableScope, TaskEntityImpl, VariableScopeImpl

    public interface VariableScope
    Interface for class that acts as a scope for variables: i.e. the implementation can be used to set and get variables. Typically, executions (and thus process instances) and tasks are the primary use case to get and set variables. The DelegateExecution for example is often used in JavaDelegate implementation to get and set variables. Variables are typically stored on the 'highest parent'. For executions, this means that when called on an execution the variable will be stored on the process instance execution. Variables can be stored on the actual scope itself though, by calling the xxLocal methods.
    • Method Detail

      • getVariables

        java.util.Map<java.lang.String,​java.lang.Object> getVariables()
        Returns all variables. This will include all variables of parent scopes too.
      • getVariableInstances

        java.util.Map<java.lang.String,​VariableInstance> getVariableInstances()
        Returns all variables, as instances of the VariableInstance interface, which gives more information than only the the value (type, execution id, etc.)
      • getVariables

        java.util.Map<java.lang.String,​java.lang.Object> getVariables​(java.util.Collection<java.lang.String> variableNames)
        Similar to getVariables(), but limited to only the variables with the provided names.
      • getVariableInstances

        java.util.Map<java.lang.String,​VariableInstance> getVariableInstances​(java.util.Collection<java.lang.String> variableNames)
        Similar to getVariableInstances(), but limited to only the variables with the provided names.
      • getVariables

        java.util.Map<java.lang.String,​java.lang.Object> getVariables​(java.util.Collection<java.lang.String> variableNames,
                                                                            boolean fetchAllVariables)
        Similar to {@link #getVariables(Collection))}, but with a flag that indicates that all variables should be fetched when fetching the specific variables. If set to false, only the specific variables will be fetched. Dependening on the use case, this can be better for performance, as it avoids fetching and processing the other variables. However, if the other variables are needed further on, getting them in one go is probably better (and the variables are cached during one Command execution).
      • getVariableInstances

        java.util.Map<java.lang.String,​VariableInstance> getVariableInstances​(java.util.Collection<java.lang.String> variableNames,
                                                                                    boolean fetchAllVariables)
        Similar to getVariables(Collection, boolean) but returns the variables as instances of the VariableInstance interface, which gives more information than only the the value (type, execution id, etc.)
      • getVariablesLocal

        java.util.Map<java.lang.String,​java.lang.Object> getVariablesLocal()
        Returns the variable local to this scope only. So, in contrary to getVariables(), the variables from the parent scope won't be returned.
      • getVariableInstancesLocal

        java.util.Map<java.lang.String,​VariableInstance> getVariableInstancesLocal()
        Returns the variables local to this scope as instances of the VariableInstance interface, which provided additional information about the variable.
      • getVariablesLocal

        java.util.Map<java.lang.String,​java.lang.Object> getVariablesLocal​(java.util.Collection<java.lang.String> variableNames)
        Similar to getVariables(Collection), but only for variables local to this scope.
      • getVariableInstancesLocal

        java.util.Map<java.lang.String,​VariableInstance> getVariableInstancesLocal​(java.util.Collection<java.lang.String> variableNames)
        Similar to getVariableInstances(Collection), but only for variables local to this scope.
      • getVariablesLocal

        java.util.Map<java.lang.String,​java.lang.Object> getVariablesLocal​(java.util.Collection<java.lang.String> variableNames,
                                                                                 boolean fetchAllVariables)
        Similar to getVariables(Collection, boolean), but only for variables local to this scope.
      • getVariableInstancesLocal

        java.util.Map<java.lang.String,​VariableInstance> getVariableInstancesLocal​(java.util.Collection<java.lang.String> variableNames,
                                                                                         boolean fetchAllVariables)
        Similar to getVariableInstances(Collection, boolean), but only for variables local to this scope.
      • getVariable

        java.lang.Object getVariable​(java.lang.String variableName)
        Returns the variable value for one specific variable. Will look in parent scopes when the variable does not exist on this particular scope.
      • getVariable

        java.lang.Object getVariable​(java.lang.String variableName,
                                     boolean fetchAllVariables)
        Similar to getVariable(String), but has an extra flag that indicates whether or not all variables need to be fetched when getting one variable. By default true (for backwards compatibility reasons), which means that calling getVariable(String) will fetch all variables, of the current scope and all parent scopes. Setting this flag to false can thus be better for performance. However, variables are cached, and if other variables are used later on, setting this true might actually be better for performance.
      • getVariableLocal

        java.lang.Object getVariableLocal​(java.lang.String variableName)
        Returns the value for the specific variable and only checks this scope and not any parent scope.
      • getVariableLocal

        java.lang.Object getVariableLocal​(java.lang.String variableName,
                                          boolean fetchAllVariables)
        Similar to getVariableLocal(String), but has an extra flag that indicates whether or not all variables need to be fetched when getting one variable. By default true (for backwards compatibility reasons), which means that calling getVariableLocal(String) will fetch all variables, of the current scope. Setting this flag to false can thus be better for performance. However, variables are cached, and if other variables are used later on, setting this true might actually be better for performance.
      • getVariable

        <T> T getVariable​(java.lang.String variableName,
                          java.lang.Class<T> variableClass)
        Typed version of the getVariable(String) method.
      • getVariableLocal

        <T> T getVariableLocal​(java.lang.String variableName,
                               java.lang.Class<T> variableClass)
        Typed version of the getVariableLocal(String) method.
      • getVariableNames

        java.util.Set<java.lang.String> getVariableNames()
        Returns all the names of the variables for this scope and all parent scopes.
      • getVariableNamesLocal

        java.util.Set<java.lang.String> getVariableNamesLocal()
        Returns all the names of the variables for this scope (no parent scopes).
      • setVariable

        void setVariable​(java.lang.String variableName,
                         java.lang.Object value)
        Sets the variable with the provided name to the provided value.

        A variable is set according to the following algorithm:

      • If this scope already contains a variable by the provided name as a local variable, its value is overwritten to the provided value.
      • If this scope does not contain a variable by the provided name as a local variable, the variable is set to this scope's parent scope, if there is one. If there is no parent scope (meaning this scope is the root scope of the hierarchy it belongs to), this scope is used. This applies recursively up the parent scope chain until, if no scope contains a local variable by the provided name, ultimately the root scope is reached and the variable value is set on that scope.
      • In practice for most cases, this algorithm will set variables to the scope of the execution at the process instance’s root level, if there is no execution-local variable by the provided name.

Parameters:
variableName - the name of the variable to be set
value - the value of the variable to be set