-
1. Re: HowTo: Use JBPM4 API (on JBoss 5)
jimdwyer Jul 29, 2009 12:41 PM (in response to djcye)I was wondering the same thing myself. Do I use JNDI, @EJB? How does it work now?
-
2. Re: HowTo: Use JBPM4 API (on JBoss 5)
jimdwyer Jul 29, 2009 4:01 PM (in response to djcye)From the usersguide, section 2.6
In JBoss, the ProcessEngine can be obtained from JNDI with
new InitialContext().lookup("java:/ProcessEngine") -
3. Re: HowTo: Use JBPM4 API (on JBoss 5)
jbarrez Jul 30, 2009 4:03 AM (in response to djcye)Exactly. If you use the demo setup provided by the distribution, you can use the ProcessEngine which is bound to JNDI. You can adapt the database configuration in the jbpm folder (under deploy) for your database.
Another solution is just to use jBPM as a standalone Jar, and creating a process engine using new Configuration().buildProcessEngine(). You can store this object in a static field for example (it's thread-safe). -
4. Re: HowTo: Use JBPM4 API (on JBoss 5)
djcye Jul 30, 2009 5:21 AM (in response to djcye)But the
"new InitialContext().lookup("java:/ProcessEngine")"
Have to take place inside the JBoss right ? Has somone an example for this ? -
5. Re: HowTo: Use JBPM4 API (on JBoss 5)
jimdwyer Jul 30, 2009 7:01 AM (in response to djcye)You need to built a little java class with a method like this:
public void startWorkflow(){
try{
InitialContext ctx = new InitialContext();
ProcessEngine processEngine = (ProcessEngine)ctx.lookup("java:/ProcessEngine");
// ProcessEngine and Services are to be used as singletons. (ie they are threadsafe)
RepositoryService repositoryService = processEngine.getRepositoryService();
ExecutionService executionService = processEngine.getExecutionService();
TaskService taskService = processEngine.getTaskService();
HistoryService historyService = processEngine.getHistoryService();
ManagementService managementService = processEngine.getManagementService();
ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncActivity");
System.out.println("ProcessId: " + processInstance.getId());
}catch (NamingException ne){
System.out.println(ne);
}
Then call that from a jsp or something.
<%jsp useBean id="bean" class="org.someco.Test" scope="session" />
<% bean.startWorkflow(); %>
Package the class and jsp into a war, deploy the war on the jboss.
That should do it.