eu.diversit.jbpm.spring
Class JbpmProcessBean

java.lang.Object
  extended by eu.diversit.jbpm.spring.JbpmProcessBean

public class JbpmProcessBean
extends java.lang.Object

Spring bean instance of a JBPM4 process.
This bean automatically connects to a ProcessEngine. The process is automatically deployed when the bean is initialized and it undeploys the process before it is destroyed.

It provides convinience methods to JBPM4 resources like ProcessEngine, ExecutionService and RepositoryService.

It provides convinience methods to start an instances of the process. Multiple process instances can be running at the same time. This bean does not maintain a list or state of started processes. That is the responsibility of JBPM. This bean does hold the process deployment id so it is not necessary to provide this when starting an process instance. It is the responsibility of the calling code to do something with the ProcessInstance if it's necessary. If needed a ProcessInstance can be looked by querying JBPM via a service.

Author:
Joost den Boer

Constructor Summary
JbpmProcessBean()
           
 
Method Summary
 void destroy()
          Unregister process when bean is destroyed.
 java.lang.String getDeploymentId()
           
 java.lang.String getProcessKey()
           
 java.lang.String getResourceName()
           
 java.lang.Object getVariable(java.lang.String processExecutionId, java.lang.String variableName)
           
 java.util.Set<java.lang.String> getVariableNames(java.lang.String processExecutionId)
           
 java.util.Map<java.lang.String,java.lang.Object> getVariables(java.lang.String processExecutionId, java.util.Set<java.lang.String> variableNames)
           
 void initialize()
          Deploy process when bean is initialized.
 void setProcessKey(java.lang.String processKey)
           
 void setResourceName(java.lang.String resourceName)
           
 org.jbpm.api.ProcessInstance startProcessInstance()
          Start a new process.
If a processKey was provided in the Spring configuration, the key will be used to create a process.
 org.jbpm.api.ProcessInstance startProcessInstanceWithKey(java.lang.String businessKey)
          Start a new process instance using a business key.
If a processKey was provided in the Spring configuration, the key will be used to create a process.
 org.jbpm.api.ProcessInstance startProcessInstanceWithKeyAndVariables(java.lang.String businessKey, java.util.Map<java.lang.String,java.lang.Object> variables)
          Start a new process instance using a business key and variables.
If a processKey was provided in the Spring configuration, the key will be used to create a process.
 org.jbpm.api.ProcessInstance startProcessInstanceWithVariables(java.util.Map<java.lang.String,java.lang.Object> variables)
          Start a new process instance using variables.
If a processKey was provided in the Spring configuration, the key will be used to create a process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JbpmProcessBean

public JbpmProcessBean()
Method Detail

initialize

@PostConstruct
@Transactional
public void initialize()
Deploy process when bean is initialized.


destroy

@PreDestroy
public void destroy()
Unregister process when bean is destroyed.


startProcessInstance

public org.jbpm.api.ProcessInstance startProcessInstance()
Start a new process.
If a processKey was provided in the Spring configuration, the key will be used to create a process. Otherwise the deployment id is used.

Returns:
Started ProcessInstance

startProcessInstanceWithKey

public org.jbpm.api.ProcessInstance startProcessInstanceWithKey(java.lang.String businessKey)
Start a new process instance using a business key.
If a processKey was provided in the Spring configuration, the key will be used to create a process. Otherwise the deployment id is used.

Parameters:
businessKey - Custom key by which this process can be tracked
Returns:
Started ProcessInstance

startProcessInstanceWithVariables

public org.jbpm.api.ProcessInstance startProcessInstanceWithVariables(java.util.Map<java.lang.String,java.lang.Object> variables)
Start a new process instance using variables.
If a processKey was provided in the Spring configuration, the key will be used to create a process. Otherwise the deployment id is used.

Parameters:
variables - Custom variables necessary for the process.
Returns:
Started ProcessInstance
See Also:
also {@link #startProcessInstanceWithKeyAndVariables(String, Map)}


startProcessInstanceWithKeyAndVariables

public org.jbpm.api.ProcessInstance startProcessInstanceWithKeyAndVariables(java.lang.String businessKey,
                                                                            java.util.Map<java.lang.String,java.lang.Object> variables)
Start a new process instance using a business key and variables.
If a processKey was provided in the Spring configuration, the key will be used to create a process. Otherwise the deployment id is used.

NOTE: Because the process is running in a Spring environment, the process is able to lookup Spring managed beans. It is therefore not necessary to pass Spring components as variables to the process. It can be done however to override a Spring component since the variables Map is searched before the Spring environement.

Parameters:
businessKey - Custom key by which this process can be tracked
variables - Custom variables necessary for the process.
Returns:
Started ProcessInstance

getVariable

public java.lang.Object getVariable(java.lang.String processExecutionId,
                                    java.lang.String variableName)
Parameters:
processExecutionId - Execution id of a process
variableName - name of variable for which to lookup the value
Returns:
Variable value
See Also:
ExecutionService.getVariable(String, String)

getVariableNames

public java.util.Set<java.lang.String> getVariableNames(java.lang.String processExecutionId)
Parameters:
processExecutionId -
Returns:
Variable names
See Also:
ExecutionService.getVariableNames(String)

getVariables

public java.util.Map<java.lang.String,java.lang.Object> getVariables(java.lang.String processExecutionId,
                                                                     java.util.Set<java.lang.String> variableNames)
Parameters:
processExecutionId -
variableNames -
Returns:
See Also:
ExecutionService.getVariables(String, Set)

getResourceName

public java.lang.String getResourceName()

setResourceName

public void setResourceName(java.lang.String resourceName)

getProcessKey

public java.lang.String getProcessKey()

setProcessKey

public void setProcessKey(java.lang.String processKey)

getDeploymentId

public java.lang.String getDeploymentId()


Copyright © 2009-2010 DiversIT Europe. All Rights Reserved.