Professional Documents
Culture Documents
com)
Maven dependencies
In order to use the client APIs, you need to add a dependency to the bonita-client artifact
in your Maven pom.xml file:
7.0.0 ... org.bonitasoft.enginebonita-client${bonita.bpm.version}
Bonita home
In order to execute this client example you need to set the Java system property
bonita.home
, for example -Dbonita.home=, and configure a Bonita Home for the client. The bonita
home used must have the same version as the Bonita BPM Engine, which is configured in
bonita.bpm.version (here 7.0.0).
Log in
The first action of the client must be to log in. This example shows how to log in when
accessing the server over HTTP:
Map settings = new HashMap
(); settings.put("server.url", "http://localhost:8080");
settings.put("application.name", "bonita");
APITypeManager.setAPITypeAndParams(ApiAccessType.HTTP, settings); //
get the LoginAPI using the TenantAPIAccessor LoginAPI loginAPI =
TenantAPIAccessor.getLoginAPI(); // log in to the tenant to create a
session APISession apiSession = loginAPI.login(username, password);
Start a process
private static void startProcess(ProcessDefinition
processDefinition) { ProcessAPI processAPI =
TenantAPIAccessor.getProcessAPI(apiSession); ProcessInstance
processInstance =
processAPI.startProcess(processDefinition.getId()); }
Execute a task
Before a user can execute a task, the task needs to be assigned to the user. The
assignUserTask method assigns the task to the user. The executeFlowNode method
executes the task.
private static void executeATask() {
processAPI.assignUserTask(taskToExecute.getId(),
session.getUserId());
processAPI.executeFlowNode(taskToExecute.getId()); }