Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-13100

Provide CommandExecutorAdapter

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Won't Do
    • L3 - Default
    • None
    • 7.14.4
    • engine
    • None

    Description

      User Story (Required on creation):

      As a process application developer, I want to be able to execute Camunda Commands outside of a Camunda initiated context transaction.

      Functional Requirements (Required before implementation):

      Being able to execute commands arbitrary from the thread local context.

      Technical Requirements (Required before implementation):

      Provide an Adapter interface that can either execute on Context or Executor.

      I have been using this frequently in various projects and came up with this solution (see hint). I would love to have this in the engine core so I do not have to re-invent it for every project.

      Hints (Optional):

      /**
      {{ * Adapter that hides the execution of a camunda {@link Command}, works with {@link org.camunda.bpm.engine.impl.interceptor.CommandContext} when called inside}}
      {{ * a camunda {@link org.camunda.bpm.engine.delegate.JavaDelegate} or Listener but uses {@link ProcessEngineConfigurationImpl#getCommandExecutorTxRequired()}}}
      {{ * to get a new context when called elsewhere.}}
      {{ */}}
      public interface CommandExecutorAdapter {

      static CommandExecutorAdapter create(CommandContext commandContext) {
          return new CommandExecutorAdapter() {
              @Override
              public <T> T execute(Command<T> command) {
                  return command.execute(commandContext);
      {{        }}}
          };
      {{ }}}

      static CommandExecutorAdapter create(ProcessEngineConfigurationImpl configuration) {
             return new CommandExecutorAdapter() {
                @Override
                public <T> T execute(Command<T> command) {
                    if (Context.getCommandContext() == null) {
                       return configuration.getCommandExecutorTxRequired().execute(command);
                    } else {
                        return command.execute(Context.getCommandContext());
      {{              }}}
               }
           };
      {{  }}}

        <T> T execute(Command<T> command);
      }

      mgm-controller-panel

        This is the controller panel for Smart Panels app

        Attachments

          Activity

            People

              thomas.martens Thomas
              jan.galinski@holisticon.de Jan Galinski
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Salesforce