A Java PAPI application should follow a certain structure. The different methods that you need to invoke before and after performing operations with PAPI determine this structure.
The ProcessService class is the main entry point to the API. Before you start using PAPI, you must create a ProcessService object.
A ProcessService acts as a factory for ProcessServiceSession objects. To create a session, you must first create and configure a ProcessService.
When you create a ProcessService object, a connection to the Directory Service is established. This connection is used to load ALBPM's environment configuration information and later to authenticate the user creating the process service session.
A ProcessServiceSession represents the dialog between a participant and the Directory Service or one or more engines.
You need a ProcessServiceSession to manage and obtain information about process instances, participants, views, and presentations.
To create a ProcessServiceSession you need to provide the valid credentials--for example, the user identifier and password--of a participant that exists in the Directory Service.
Once you obtain a ProcessServiceSession you are ready to query for information and invoke any of the operations provided by PAPI.
You need to close PAPI sessions before your application finishes so that caches are cleared and the connections to the engine are closed.
Leaving sessions open may both cause a memory leak and use network resources unnecessarily. This is because the allocated resources are never freed and the Engine continues to send information to the connected participant.
Leaving sessions open can also cause problems in updating a participant’s role assignment. Because changes to role assignments are applied only after the last session has been closed, leaving a session open indefinitely means that changes to roles and permissions are never applied.
PAPI sessions do not expire by timing out. The application using PAPI is responsible for closing open sessions.
Once the session is closed it cannot be used again. Trying to invoke a method over a closed session results in an exception.
It is advisable to close the ProcessService so that the resources it uses are released.