Chapter 10. Services

10.1. Introduction

All session facades are called services in the PVM and it's related projects. A service is the front door of the API. It has a number of methods that expose the functionality of the component. The service takes care of getting or setting up an environment for each operation that is invoked.

10.2. PvmService

The class org.jbpm.PvmService is the main way to access functionality from the PVM.

10.3. Architecture

Service methods are implemented through command classes. Each method creates a command object and the command is executed with the execute method of the CommandService. The CommandService is responsible for setting up the environment.

There are three command executors:

  • standard-command-service will just execute the command and pass in the current environment.
  • (UNTESTED) async-command-service will send an asynchronous message. So right after that in a separate transaction, the message is consumed and the command is executed.
  • (TODO) cmt-command-service will delegate execution of the command to a local SLSB that has transaction attribute required.
  • (TODO) remote-command-service will delegate execution of the command to a remote SLSB.

Each of the command services can be configured with a list of interceptors that span around the command execution. Following interceptors are available:

  • environment-interceptor: Will execute the command within an environment block.
  • (UNTESTED) authorization-interceptor: Will perform an authrorization check before the command is executed. The authorization interceptor will look up the AuthorizationSession from the environment to delegate the actual authorization check to.
  • retry-interceptor: Will catch hibernate's optmistic locking exceptions (StaleStateException) and retries to execute the command for a configurable number of times
  • transaction-interceptor: Will get the transaction from the current context and invoke setRollbackOnly() on it in case an exception comes out of the command execution.

Following configuration can be used in default standard persistence situations:

<environment>
  <application>
    
    <pvm-service />

    <standard-command-service>
      <retry-interceptor />
      <environment-interceptor />
      <transaction-interceptor />
    </standard-command-service>
    
    ...
  </application>
  ...
  
</environment>