JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
TaskInstance taskInstance = ...
...do your process operations...
// in case you update a process object that was not fetched
// with a ...ForUpdate method, you have to save it.
jbpmContext.save(processInstance);
finally {
jbpmContext.close();
}
A JbpmContext separates jBPM from a sprecific environment.
For each service that jBPM uses, there is an interface specified in the jBPM codebase.
jBPM also includes implementations that implement these services by using services in a
specific environment. e.g. a hibernate session, a JMS asynchronous messaging system, ...
A JbpmContext can demarcate a transaction. When a PersistenceService is fetched from
the JbpmContext, the default implementation for the persistence service will create
a hibernate session and start a transaction. So that transactions can be configured
in the hibernate configuration.
A JbpmContext allows the user to overwrite (or make complete) the configuration
by injecting objects programmatically. like e.g. a hibernate session factory or
a hibernate session or any other resource that can be fetched or created from the
configuration.
getGroupTaskList(List actorIds) fetches all the task instances for which at least one of the given
actorIds is a candidate (pooled actor).
Typically, for an actor, his/her personal actorId plus
all the actorIds representing the groups that person belongs
to form the actorIds.
getTaskInstanceForUpdate(long taskInstanceId) gets a task instance from the db and registers it for auto-save.
The loaded task instance will be save automatically at the
JbpmContext.close() .
This is a convenience method in case you plan to do update operations on
this task instance.
the task instance or null in case no such task instance exists.
newProcessInstanceForUpdate(String processDefinitionName) creates a new process instance for the latest version of the process definition
with the given name and registers it for auto-save.
save(Token token) saves the complete process instance for this token.
public void
save(TaskInstance taskInstance) saves the complete process instance for this task instance.
public void
setActorId(String actorId) sets the currently authenticated actorId.
public void
setConnection(Connection connection) allows users to provide a jdbc connection to be used when the hibernate
session is created.
public void
setRollbackOnly() mark this transaction for rollback only in the persistence service.
public void
setSession(Session session) sets the hibernate session into the default configured persistence
service, preventing the creation of a session from the configured
session factory (if there is one configured).
public void
setSessionFactory(SessionFactory sessionFactory) sets the hibernate session factory into the default configured persistence
service, overwriting the configured session factory (if there is one configured).
Field Detail
DEFAULT_JBPM_CONTEXT_NAME
final public static String DEFAULT_JBPM_CONTEXT_NAME(Code)
gets the jdbc connection from the default configured persistence service.
throws: ClassCastException - if another persistence service is configured then the default.
obtains the current JbpmContext from a thread local.
The current JbpmContexts are maintained in a stack so
that you can do nested context operations for
different jbpm configurations.
JbpmConfiguration
fetches all the task instances for which at least one of the given
actorIds is a candidate (pooled actor).
Typically, for an actor, his/her personal actorId plus
all the actorIds representing the groups that person belongs
to form the actorIds. Then the user interface should show
only the option to take these tasks to the actor's personal
task list (with
TaskInstance.setActorId(String) ). Only
task instances that are assigned to the actor directly should be
offered the possibility for performing the actual task.
returns the process instance with the given key or null if no such instance exists.
Upon close of this jbpmContext, the fetched process instance will be automatically saved.
gets the hibernate session from the default configured persistence
service.
throws: ClassCastException - if another persistence service is configured then the default.
gets the hibernate session factory from the default configured persistence
service.
throws: ClassCastException - if another persistence service is configured then the default.
fetches the tasklist for the current authenticated actor. With the default
configured authentication service, you can set the authenticated user
with
JbpmContext.setActorId(String) , then all the subsequent operations will
be performed on behalf of that actor.
returns the process instance with the given key or throws an exception if no
such instance exists.
Upon close of this jbpmContext, the fetched process instance will be automatically saved.
creates a new process instance for the latest version of the process definition
with the given name.
throws: JbpmException - when no processDefinition with the given name is deployed.
creates a new process instance for the latest version of the process definition
with the given name and registers it for auto-save.
throws: JbpmException - when no processDefinition with the given name is deployed.
allows users to provide a jdbc connection to be used when the hibernate
session is created.
throws: ClassCastException - if another persistence service is configured then the default.
sets the hibernate session into the default configured persistence
service, preventing the creation of a session from the configured
session factory (if there is one configured).
throws: ClassCastException - if another persistence service is configured then the default.
setSessionFactory
public void setSessionFactory(SessionFactory sessionFactory)(Code)
sets the hibernate session factory into the default configured persistence
service, overwriting the configured session factory (if there is one configured).
throws: ClassCastException - if another persistence service is configured then the default.