Class VariableScopeImpl

    • Field Detail

      • transientVariabes

        protected java.util.Map<java.lang.String,​VariableInstance> transientVariabes
      • cachedElContext

        protected javax.el.ELContext cachedElContext
    • Constructor Detail

      • VariableScopeImpl

        public VariableScopeImpl()
    • Method Detail

      • loadVariableInstances

        protected abstract java.util.Collection<VariableInstanceEntity> loadVariableInstances()
      • getParentVariableScope

        protected abstract VariableScopeImpl getParentVariableScope()
      • initializeVariableInstanceBackPointer

        protected abstract void initializeVariableInstanceBackPointer​(VariableInstanceEntity variableInstance)
      • ensureVariableInstancesInitialized

        protected void ensureVariableInstancesInitialized()
      • getVariables

        public java.util.Map<java.lang.String,​java.lang.Object> getVariables()
        Description copied from interface: VariableScope
        Returns all variables. This will include all variables of parent scopes too.
        Specified by:
        getVariables in interface VariableScope
      • getVariables

        public java.util.Map<java.lang.String,​java.lang.Object> getVariables​(java.util.Collection<java.lang.String> variableNames)
        Description copied from interface: VariableScope
        Similar to VariableScope.getVariables(), but limited to only the variables with the provided names.
        Specified by:
        getVariables in interface VariableScope
      • getVariables

        public java.util.Map<java.lang.String,​java.lang.Object> getVariables​(java.util.Collection<java.lang.String> variableNames,
                                                                                   boolean fetchAllVariables)
        Description copied from interface: VariableScope
        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).
        Specified by:
        getVariables in interface VariableScope
      • collectVariables

        protected java.util.Map<java.lang.String,​java.lang.Object> collectVariables​(java.util.HashMap<java.lang.String,​java.lang.Object> variables)
      • collectVariableInstances

        protected java.util.Map<java.lang.String,​VariableInstance> collectVariableInstances​(java.util.HashMap<java.lang.String,​VariableInstance> variables)
      • getVariable

        public java.lang.Object getVariable​(java.lang.String variableName)
        Description copied from interface: VariableScope
        Returns the variable value for one specific variable. Will look in parent scopes when the variable does not exist on this particular scope.
        Specified by:
        getVariable in interface VariableScope
      • getVariable

        public java.lang.Object getVariable​(java.lang.String variableName,
                                            boolean fetchAllVariables)
        The same operation as getVariable(String), but with an extra parameter to indicate whether or not all variables need to be fetched. Note that the default Activiti way (because of backwards compatibility) is to fetch all the variables when doing a get/set of variables. So this means 'true' is the default value for this method, and in fact it will simply delegate to getVariable(String). This can also be the most performant, if you're doing a lot of variable gets in the same transaction (eg in service tasks). In case 'false' is used, only the specific variable will be fetched.
        Specified by:
        getVariable in interface VariableScope
      • getSpecificVariable

        protected abstract VariableInstanceEntity getSpecificVariable​(java.lang.String variableName)
      • getVariableLocal

        public java.lang.Object getVariableLocal​(java.lang.String variableName)
        Description copied from interface: VariableScope
        Returns the value for the specific variable and only checks this scope and not any parent scope.
        Specified by:
        getVariableLocal in interface VariableScope
      • getVariableLocal

        public java.lang.Object getVariableLocal​(java.lang.String variableName,
                                                 boolean fetchAllVariables)
        Description copied from interface: VariableScope
        Similar to VariableScope.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 VariableScope.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.
        Specified by:
        getVariableLocal in interface VariableScope
      • hasVariables

        public boolean hasVariables()
        Description copied from interface: VariableScope
        Returns whether this scope or any parent scope has variables.
        Specified by:
        hasVariables in interface VariableScope
      • hasVariable

        public boolean hasVariable​(java.lang.String variableName)
        Description copied from interface: VariableScope
        Returns whether this scope or any parent scope has a specific variable.
        Specified by:
        hasVariable in interface VariableScope
      • hasVariableLocal

        public boolean hasVariableLocal​(java.lang.String variableName)
        Description copied from interface: VariableScope
        Returns whether this scope has a specific variable.
        Specified by:
        hasVariableLocal in interface VariableScope
      • collectVariableNames

        protected java.util.Set<java.lang.String> collectVariableNames​(java.util.Set<java.lang.String> variableNames)
      • getVariableNames

        public java.util.Set<java.lang.String> getVariableNames()
        Description copied from interface: VariableScope
        Returns all the names of the variables for this scope and all parent scopes.
        Specified by:
        getVariableNames in interface VariableScope
      • getVariablesLocal

        public java.util.Map<java.lang.String,​java.lang.Object> getVariablesLocal()
        Description copied from interface: VariableScope
        Returns the variable local to this scope only. So, in contrary to VariableScope.getVariables(), the variables from the parent scope won't be returned.
        Specified by:
        getVariablesLocal in interface VariableScope
      • getSpecificVariables

        protected abstract java.util.List<VariableInstanceEntity> getSpecificVariables​(java.util.Collection<java.lang.String> variableNames)
      • getVariableNamesLocal

        public java.util.Set<java.lang.String> getVariableNamesLocal()
        Description copied from interface: VariableScope
        Returns all the names of the variables for this scope (no parent scopes).
        Specified by:
        getVariableNamesLocal in interface VariableScope
      • getVariableInstanceEntities

        public java.util.Map<java.lang.String,​VariableInstanceEntity> getVariableInstanceEntities()
      • getUsedVariablesCache

        public java.util.Map<java.lang.String,​VariableInstanceEntity> getUsedVariablesCache()
      • createVariablesLocal

        public void createVariablesLocal​(java.util.Map<java.lang.String,​? extends java.lang.Object> variables)
      • setVariables

        public void setVariables​(java.util.Map<java.lang.String,​? extends java.lang.Object> variables)
        Description copied from interface: VariableScope
        Sets the provided variables to the variable scope.

        Variables are set according algorithm for VariableScope.setVariable(String, Object), applied separately to each variable.

        Specified by:
        setVariables in interface VariableScope
        Parameters:
        variables - a map of keys and values for the variables to be set
      • setVariable

        public void setVariable​(java.lang.String variableName,
                                java.lang.Object value)
        Description copied from interface: VariableScope
        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.

Specified by:
setVariable in interface VariableScope
Parameters:
variableName - the name of the variable to be set
value - the value of the variable to be set