hm
but how do i reuse a jbpm context with different classes ?
i want to write some classes as an example how to use jbpm for our univeristy.
so i want to deploy a process definition. close the program
then i want to start a programm which uses this context, too and starts a process
instance
and there should be one more program that shows all open tasks
so actually i have to keep the programm running all the time ? it should be more like a
server / client
i have the jbpm server running (starters kit) but it seems that eclipse only starts a
"local" jbpm contaxt which is lost after my programm has terminated
thats the programm that works:
package de.fhkl.bda;
|
| import java.util.List;
| import java.util.Map;
| import java.util.Set;
|
| import org.jbpm.JbpmConfiguration;
| import org.jbpm.JbpmContext;
| import org.jbpm.db.GraphSession;
| import org.jbpm.graph.def.ProcessDefinition;
| import org.jbpm.graph.exe.ProcessInstance;
| import org.jbpm.graph.exe.Token;
| import org.jbpm.identity.Entity;
| import org.jbpm.identity.xml.IdentityXmlParser;
|
| public class TestClass {
| private static String actorID = "1";
| /**
| * @param args
| */
| public static void main(String[] args) {
| JbpmConfiguration.getInstance().createSchema();
| JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
|
| try {
| GraphSession graphSession = jbpmContext.getGraphSession();
|
| deployProcessDefinition(graphSession);
|
| findAllProcessDefinitions(graphSession);
|
|
| ProcessDefinition processDefinition =
findProcessDefinitionsFromServer("SimpleDefinition1", graphSession);
| System.out.println(processDefinition.getId());
| }
| finally {
| jbpmContext.close();
| }
| }
|
| public static void deployProcessDefinition(GraphSession graphSession) {
| ProcessDefinition processDefinition = ProcessDefinition
| .parseXmlString( "<process-definition
name='SimpleDefinition1'>"
| + " <start-state name='start'>"
| + " <transition to='s' />"
| + " </start-state>"
| + " <state name='s'>"
| + " <transition to='t' />"
| + " </state>"
| + " <state name='t'>"
| + " <transition to='end' />"
| + " </state>"
| + " <end-state name='end' />"
| + "</process-definition>" );
| graphSession.deployProcessDefinition(processDefinition);
| graphSession.saveProcessDefinition(processDefinition);
| }
|
| public static ProcessDefinition findProcessDefinitionsFromServer(String name,
GraphSession graphSession) {
| ProcessDefinition processDefinition =
| graphSession.findLatestProcessDefinition(name);
| if(processDefinition == null) System.out.println("No process definitions found
for '" + name + "' !!!");
| return processDefinition;
| }
|
| public static void findAllProcessDefinitions(GraphSession graphSession) {
| System.out.println(graphSession.findAllProcessDefinitions());
| }
| }
|
But as i told above i want to re-use the same context in several different programs.
so how can i use the server to store it forever ?
now i guess why i cant find anything i deployed / started in earlier times
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3962138#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...