Diogo,
You can check how it is used in console:
https://github.com/droolsjbpm/jbpm/blob/master/jbpm-gwt/jbpm-gwt-graph/src/main/java/org/jbpm/integration/console/graph/GraphViewerPluginImpl.java
Or for example this test:
https://github.com/calcacuervo/JBPM5-Samples/blob/master/human-tasks/src/test/java/com/test/HumanTaskTest.java
Basically, you create a logger to save information in bam tables:
new JPAWorkingMemoryDbLogger(session);
and then you can use a
JPAProcessInstanceDbLog processLog = new JPAProcessInstanceDbLog(session.getEnvironment());
to get the information with its methods:
findProcessInstances()
findProcessInstance(processInstanceId)
findNodesInstances(processInstances)
findVariableInstances(processInstances)
etc
Regards,
Demian