Class VariableBehavior


  • public final class VariableBehavior
    extends Object
    A behavior which allows processors to mutate the variable state. Use this anywhere where you would want to set a variable during processing.

    Note that for EventApplier, you should just use the mutable state directly.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void mergeDocument​(long scopeKey, long processDefinitionKey, long processInstanceKey, org.agrona.DirectBuffer document)
      Merges the given document, propagating its changes from the bottom to the top of the scope hierarchy.
      void mergeLocalDocument​(long scopeKey, long processDefinitionKey, long processInstanceKey, org.agrona.DirectBuffer document)
      Merges the given document directly on the given scope key.
      void setLocalVariable​(long scopeKey, long processDefinitionKey, long processInstanceKey, org.agrona.DirectBuffer name, org.agrona.DirectBuffer value, int valueOffset, int valueLength)
      Publishes a follow up event to create or update the variable with name name on the given scope with key scopeKey, with additional processDefinitionKey and processInstanceKey context.
    • Method Detail

      • mergeLocalDocument

        public void mergeLocalDocument​(long scopeKey,
                                       long processDefinitionKey,
                                       long processInstanceKey,
                                       org.agrona.DirectBuffer document)
        Merges the given document directly on the given scope key.

        If any variable from the document already exists on the current scope, a Variable.UPDATED record is produced as a follow up event.

        For all variables from the document which do not exist in the current scope, a Variable.CREATED record is produced as a follow up event.

        Parameters:
        scopeKey - the scope key for each variable
        processDefinitionKey - the process key to be associated with each variable
        processInstanceKey - the process instance key to be associated with each variable
        document - the document to merge
      • mergeDocument

        public void mergeDocument​(long scopeKey,
                                  long processDefinitionKey,
                                  long processInstanceKey,
                                  org.agrona.DirectBuffer document)
        Merges the given document, propagating its changes from the bottom to the top of the scope hierarchy.

        Starting at the given scopeKey, it will overwrite any variables that exist in that scope with the corresponding values from the given document. Variables that were not set because they did not exist in the current scope are collected as a sub document, which will then be merged with the parent scope, recursively, until there are no more. If we reach a scope with no parent, then any remaining variables are created there.

        If any variable from the document already exists on the current scope, a Variable.UPDATED record is produced as a follow up event.

        For all variables from the document which do not exist in the current scope, a Variable.CREATED record is produced as a follow up event.

        Parameters:
        scopeKey - the scope key for each variable
        processDefinitionKey - the process key to be associated with each variable
        processInstanceKey - the process instance key to be associated with each variable
        document - the document to merge
      • setLocalVariable

        public void setLocalVariable​(long scopeKey,
                                     long processDefinitionKey,
                                     long processInstanceKey,
                                     org.agrona.DirectBuffer name,
                                     org.agrona.DirectBuffer value,
                                     int valueOffset,
                                     int valueLength)
        Publishes a follow up event to create or update the variable with name name on the given scope with key scopeKey, with additional processDefinitionKey and processInstanceKey context.

        If the scope is the process instance itself, then scopeKey should be equal to processInstanceKey.

        Parameters:
        scopeKey - the key of the scope on which to set the variable
        processDefinitionKey - the associated process key
        processInstanceKey - the associated process instance key
        name - a buffer containing only the name of the variable
        value - a buffer containing the value of the variable as MessagePack
        valueOffset - the offset of the value in the value buffer
        valueLength - the length of the value in the value buffer