|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jbpm.JbpmContext
public class JbpmContext
is used to surround persistent operations to processes.
Obtain JbpmContext's via JbpmConfiguration.createJbpmContext()
and put it in a
try-finally block like this:
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.
Last but not least, JbpmContext provides convenient access to the most common operations such as
getTaskList(String)
, newProcessInstance(String)
loadTaskInstanceForUpdate(long)
and save(ProcessInstance)
.
All the ...ForUpdate(...)
methods will automatically save the loaded objects at
jbpmContext.close();
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_JBPM_CONTEXT_NAME
|
Constructor Summary | |
---|---|
JbpmContext(Services services,
ObjectFactory objectFactory)
normally, JbpmContext object are created via a JbpmConfiguration . |
Method Summary | |
---|---|
void |
addAutoSaveProcessInstance(ProcessInstance processInstance)
|
void |
addAutoSaveTaskInstance(TaskInstance taskInstance)
|
void |
addAutoSaveToken(Token token)
|
void |
close()
make sure you close your JbpmContext in a finally block. |
void |
deployProcessDefinition(ProcessDefinition processDefinition)
deploys a process definition. |
java.lang.String |
getActorId()
retrieves the current authenticated actor from the authentication service. |
java.sql.Connection |
getConnection()
gets the jdbc connection from the default configured persistence service. |
ContextSession |
getContextSession()
more variables related database access. |
static JbpmContext |
getCurrentJbpmContext()
obtains the current JbpmContext from a thread local. |
GraphSession |
getGraphSession()
more graph (process) related database access. |
java.util.List |
getGroupTaskList(java.util.List actorIds)
fetches all the task instances for which at least one of the given actorIds is a candidate (pooled actor). |
JbpmConfiguration |
getJbpmConfiguration()
|
JobSession |
getJobSession()
more job related database access. |
LoggingSession |
getLoggingSession()
more logging related database access. |
ObjectFactory |
getObjectFactory()
gives access to the object factory containing the configuration for creating the service factories. |
ProcessInstance |
getProcessInstance(long processInstanceId)
gets a process instance from the db. |
ProcessInstance |
getProcessInstance(ProcessDefinition processDefinition,
java.lang.String key)
returns the process instance with the given key or null if no such instance exists. |
ProcessInstance |
getProcessInstanceForUpdate(long processInstanceId)
gets a process instances from the db and registers it for auto-save. |
ProcessInstance |
getProcessInstanceForUpdate(ProcessDefinition processDefinition,
java.lang.String key)
returns the process instance with the given key or null if no such instance exists. |
ServiceFactory |
getServiceFactory(java.lang.String name)
|
Services |
getServices()
gives access to the services and service factories. |
org.hibernate.Session |
getSession()
gets the hibernate session from the default configured persistence service. |
org.hibernate.SessionFactory |
getSessionFactory()
gets the hibernate session factory from the default configured persistence service. |
TaskInstance |
getTaskInstance(long taskInstanceId)
gets a task instance from the db. |
TaskInstance |
getTaskInstanceForUpdate(long taskInstanceId)
gets a task instance from the db and registers it for auto-save. |
java.util.List |
getTaskList()
fetches the tasklist for the current authenticated actor. |
java.util.List |
getTaskList(java.lang.String actorId)
fetches the tasklist for the given actor. |
TaskMgmtSession |
getTaskMgmtSession()
more task related database access. |
Token |
getToken(long tokenId)
gets a token from the db. |
Token |
getTokenForUpdate(long tokenId)
get a token from the db and registers it for auto-save. |
ProcessInstance |
loadProcessInstance(long processInstanceId)
loads a process instance from the db. |
ProcessInstance |
loadProcessInstance(ProcessDefinition processDefinition,
java.lang.String key)
returns the process instance with the given key or throws an exception if no such instance exists. |
ProcessInstance |
loadProcessInstanceForUpdate(long processInstanceId)
loads a process instances from the db and registers it for auto-save. |
ProcessInstance |
loadProcessInstanceForUpdate(ProcessDefinition processDefinition,
java.lang.String key)
returns the process instance with the given key or throws an exception if no such instance exists. |
TaskInstance |
loadTaskInstance(long taskInstanceId)
loads a task instance from the db. |
TaskInstance |
loadTaskInstanceForUpdate(long taskInstanceId)
loads a task instance from the db and registers it for auto-save. |
Token |
loadToken(long tokenId)
loads a token from the db. |
Token |
loadTokenForUpdate(long tokenId)
loads a token from the db and registers it for auto-save. |
ProcessInstance |
newProcessInstance(java.lang.String processDefinitionName)
creates a new process instance for the latest version of the process definition with the given name. |
ProcessInstance |
newProcessInstanceForUpdate(java.lang.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. |
void |
save(ProcessInstance processInstance)
saves the process instance. |
void |
save(TaskInstance taskInstance)
saves the complete process instance for this task instance. |
void |
save(Token token)
saves the complete process instance for this token. |
void |
setActorId(java.lang.String actorId)
sets the currently authenticated actorId. |
void |
setConnection(java.sql.Connection connection)
allows users to provide a jdbc connection to be used when the hibernate session is created. if a nonstandard persistence service is configured, then this call has no effect. |
void |
setRollbackOnly()
mark this transaction for rollback only in the persistence service. |
void |
setSession(org.hibernate.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). if a nonstandard persistence service is configured, then this call has no effect. |
void |
setSessionFactory(org.hibernate.SessionFactory sessionFactory)
sets the hibernate session factory into the default configured persistence service, overwriting the configured session factory (if there is one configured). if a nonstandard persistence service is configured, then this call has no effect. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT_JBPM_CONTEXT_NAME
Constructor Detail |
---|
public JbpmContext(Services services, ObjectFactory objectFactory)
JbpmConfiguration
.
Method Detail |
---|
public void close()
public static JbpmContext getCurrentJbpmContext()
it is strongly recommended that client code invokes
JbpmConfiguration.getCurrentJbpmContext()
in preference to this method.
public void deployProcessDefinition(ProcessDefinition processDefinition)
ProcessDefinition
.
public java.util.List getTaskList()
setActorId(String)
,
then all the subsequent operations will be performed on behalf of that actor.
public java.util.List getTaskList(java.lang.String actorId)
public java.util.List getGroupTaskList(java.util.List actorIds)
TaskInstance.setActorId(String)
). Only task instances that are assigned to the actor
directly should be offered the possibility for performing the actual task.
public TaskInstance loadTaskInstance(long taskInstanceId)
JbpmException
- in case no such task instance existsgetTaskInstance(long)
,
loadTaskInstanceForUpdate(long)
,
getTaskInstanceForUpdate(long)
public TaskInstance getTaskInstance(long taskInstanceId)
loadTaskInstance(long)
,
loadTaskInstanceForUpdate(long)
,
getTaskInstanceForUpdate(long)
public TaskInstance loadTaskInstanceForUpdate(long taskInstanceId)
close()
. This is a convenience method in case you plan to
do update operations on this task instance.
JbpmException
- in case no such task instance existsloadTaskInstance(long)
,
getTaskInstance(long)
,
getTaskInstanceForUpdate(long)
public TaskInstance getTaskInstanceForUpdate(long taskInstanceId)
close()
. This is a convenience method in case you plan to
do update operations on this task instance.
loadTaskInstance(long)
,
getTaskInstance(long)
,
loadTaskInstanceForUpdate(long)
public Token loadToken(long tokenId)
JbpmException
- in case no such token exists.getToken(long)
,
loadTokenForUpdate(long)
,
getTokenForUpdate(long)
public Token getToken(long tokenId)
loadToken(long)
,
loadTokenForUpdate(long)
,
getTokenForUpdate(long)
public Token loadTokenForUpdate(long tokenId)
save(Token)
d automatically at the close()
. This is a convenience method in
case you plan to do update operations on this token.
JbpmException
- in case no such token exists.getToken(long)
,
loadToken(long)
,
getTokenForUpdate(long)
public Token getTokenForUpdate(long tokenId)
save(Token)
d automatically at the close()
. This is a convenience method in
case you plan to do update operations on this token.
getToken(long)
,
loadToken(long)
,
loadTokenForUpdate(long)
public ProcessInstance loadProcessInstance(long processInstanceId)
loadProcessInstanceForUpdate(long)
if you plan to perform an update operation on the
process instance.
JbpmException
- in case no such process instance exists.getProcessInstance(long)
,
loadProcessInstanceForUpdate(long)
,
getProcessInstanceForUpdate(long)
public ProcessInstance getProcessInstance(long processInstanceId)
loadProcessInstanceForUpdate(long)
if you plan to perform an update operation on the process instance.
loadProcessInstance(long)
,
loadProcessInstanceForUpdate(long)
,
getProcessInstanceForUpdate(long)
public ProcessInstance loadProcessInstanceForUpdate(long processInstanceId)
save(ProcessInstance)
d automatically at the close()
. This is
a convenience method in case you plan to do update operations on this process instance.
JbpmException
- in case no such process instance exists.loadProcessInstance(long)
,
getProcessInstance(long)
,
getProcessInstanceForUpdate(long)
public ProcessInstance getProcessInstanceForUpdate(long processInstanceId)
save(ProcessInstance)
d automatically at the close()
. This is
a convenience method in case you plan to do update operations on this process instance.
loadProcessInstance(long)
,
getProcessInstance(long)
,
loadProcessInstanceForUpdate(long)
public ProcessInstance getProcessInstance(ProcessDefinition processDefinition, java.lang.String key)
public ProcessInstance loadProcessInstance(ProcessDefinition processDefinition, java.lang.String key)
public ProcessInstance getProcessInstanceForUpdate(ProcessDefinition processDefinition, java.lang.String key)
public ProcessInstance loadProcessInstanceForUpdate(ProcessDefinition processDefinition, java.lang.String key)
public ProcessInstance newProcessInstance(java.lang.String processDefinitionName)
JbpmException
- when no processDefinition with the given name is deployed.public ProcessInstance newProcessInstanceForUpdate(java.lang.String processDefinitionName)
JbpmException
- when no processDefinition with the given name is deployed.public void save(ProcessInstance processInstance)
public void save(Token token)
public void save(TaskInstance taskInstance)
public void setRollbackOnly()
close()
operation will then perform a rollback.
public Services getServices()
public ServiceFactory getServiceFactory(java.lang.String name)
public ObjectFactory getObjectFactory()
public org.hibernate.SessionFactory getSessionFactory()
null
if a nonstandard persistence
service is configuredpublic void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
public org.hibernate.Session getSession()
null
if a nonstandard persistence service is
configured.public void setSession(org.hibernate.Session session)
public java.sql.Connection getConnection()
null
if a nonstandard persistence service is
configured.public void setConnection(java.sql.Connection connection)
public ContextSession getContextSession()
public LoggingSession getLoggingSession()
public JobSession getJobSession()
public GraphSession getGraphSession()
public TaskMgmtSession getTaskMgmtSession()
public java.lang.String getActorId()
public void setActorId(java.lang.String actorId)
public void addAutoSaveProcessInstance(ProcessInstance processInstance)
public void addAutoSaveToken(Token token)
public void addAutoSaveTaskInstance(TaskInstance taskInstance)
public JbpmConfiguration getJbpmConfiguration()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |