|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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 |
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()
Deprecated. method moved to JbpmConfiguration . |
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()
|
LoggingSession |
getLoggingSession()
more logging related database access. |
MessagingSession |
getMessagingSession()
more messaging 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 |
getProcessInstanceForUpdate(long processInstanceId)
gets a process instances from the db and registers it for auto-save. |
SchedulerSession |
getSchedulerSession()
more scheduling related database access. |
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 |
loadProcessInstanceForUpdate(long processInstanceId)
loads a process instances from the db and registers it for auto-save. |
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. |
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). |
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). |
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()
JbpmConfiguration
.
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 newProcessInstance(java.lang.String processDefinitionName)
public ProcessInstance newProcessInstanceForUpdate(java.lang.String processDefinitionName)
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()
java.lang.ClassCastException
- if another persistence service is configured then the default.public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
java.lang.ClassCastException
- if another persistence service is configured then the default.public org.hibernate.Session getSession()
java.lang.ClassCastException
- if another persistence service is configured then the default.public void setSession(org.hibernate.Session session)
java.lang.ClassCastException
- if another persistence service is configured then the default.public java.sql.Connection getConnection()
java.lang.ClassCastException
- if another persistence service is configured then the default.public void setConnection(java.sql.Connection connection)
java.lang.ClassCastException
- if another persistence service is configured then the default.public ContextSession getContextSession()
public LoggingSession getLoggingSession()
public MessagingSession getMessagingSession()
public SchedulerSession getSchedulerSession()
public GraphSession getGraphSession()
public TaskMgmtSession getTaskMgmtSession()
public java.lang.String getActorId()
public void setActorId(java.lang.String actorId)
java.lang.ClassCastException
- if another authentication service is configured then the default.public JbpmConfiguration getJbpmConfiguration()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |