[JBoss jBPM] - Re: jbpm 4.0 creating and running processes without persiste
by mihailrc
I managed to run a process without persistence.
Here is the code:
| import junit.framework.TestCase;
| import org.jbpm.jpdl.internal.model.JpdlProcessDefinition;
| import org.jbpm.jpdl.internal.xml.JpdlParser;
| import org.jbpm.jpdl.internal.activity.StartActivity;
| import org.jbpm.jpdl.internal.activity.StateActivity;
| import org.jbpm.jpdl.internal.activity.EndActivity;
| import org.jbpm.pvm.internal.model.ActivityImpl;
| import org.jbpm.pvm.internal.model.TransitionImpl;
| import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
| import org.jbpm.pvm.internal.client.ClientExecution;
| import org.jbpm.pvm.internal.xml.Parse;
| import org.jbpm.api.activity.ActivityExecution;
| import org.jbpm.api.activity.ExternalActivityBehaviour;
|
| import java.io.FileInputStream;
| import java.io.IOException;
| import java.util.Map;
|
| public class HelloWorldTest extends TestCase {
| public void test_helloWorldProcess() throws IOException {
| ProcessDefinitionImpl processDefinition = createProcessDefinition();
| ClientExecution execution = processDefinition.startProcessInstance();
| System.out.println("State After start : " + execution.findActiveActivityNames());
| execution.signal();
| System.out.println("State after signal: " + execution.findActiveActivityNames());
|
| }
|
| private ProcessDefinitionImpl createProcessDefinition() {
| ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();
| processDefinition.setName("hello");
| //define states
| ActivityImpl start = processDefinition.createActivity("start");
| start.setBehaviour(new StartActivity());
| //it turns out is very important to call this since it says where the process starts
| processDefinition.setInitial(start);
| ActivityImpl state1 = processDefinition.createActivity("state1");
| state1.setBehaviour(new HelloActivity());
| ActivityImpl state2 = processDefinition.createActivity("state2");
| state2.setBehaviour(new StateActivity());
| ActivityImpl end = processDefinition.createActivity("end");
| end.setBehaviour(new EndActivity());
| //define transitions
| TransitionImpl transition = start.createOutgoingTransition();
| transition.setDestination(state1);
| TransitionImpl transition2 = state1.createOutgoingTransition();
| transition2.setDestination(state2);
| TransitionImpl endTransition = state2.createOutgoingTransition();
| endTransition.setDestination(end);
| return processDefinition;
| }
|
|
| private JpdlProcessDefinition loadProcessDefinition() throws IOException {
| JpdlParser jpdlParser = new JpdlParser();
| Parse parse = jpdlParser.createParse();
| FileInputStream inputStream = new FileInputStream("process.jpdl.xml");
| parse.setInputStream(inputStream);
| parse.execute();
| return (JpdlProcessDefinition) parse.getDocumentObject();
| }
|
| class HelloActivity implements ExternalActivityBehaviour {
| public void signal(ActivityExecution activityExecution, String signalName, Map<String, ?> stringMap) throws Exception {
| activityExecution.take(signalName);
| }
|
| public void execute(ActivityExecution activityExecution) throws Exception {
| System.out.println("=================Hello there===========");
| activityExecution.waitForSignal();
| }
| }
| }
|
|
As you can see it uses the internal API quite a bit.
Mihail
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4245936#4245936
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4245936
16 years, 8 months
[JBoss jBPM] - where can I find this class
by somechina
hi all!
i use jbpm4.0 ga in my project ,
in jbpm.jar i add the hibernate mapping file jbpm.jpd.hbm.xml to my hibernate configuration file at mappinglocation ,when app loading , my server throws proxy classs ont find exception :org.jbpm.jpdl.internal.model.JpdlExecution
the flowwing code is jbpm.jpdl.hbm.xml content
| <?xml version="1.0"?>
| <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
| <hibernate-mapping default-access="field">
|
| <subclass name="org.jbpm.jpdl.internal.model.JpdlExecution"
| extends="org.jbpm.pvm.internal.model.ExecutionImpl"
| discriminator-value="jpdl">
|
| <map name="swimlanes"
| cascade="all-delete-orphan">
| <key foreign-key="FK_SWIMLANE_EXEC">
| <column name="EXECUTION_" index="IDX_SWIMLANE_EXEC"/>
| </key>
| <map-key type="string" column="NAME_" />
| <one-to-many class="org.jbpm.pvm.internal.task.SwimlaneImpl" />
| </map>
| </subclass>
|
| </hibernate-mapping>
|
i have ever checkout src of pvm and api ,i alse cound't find this classs ,is this a obvisiably bug ?????????? hope to answer!!!!!
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4245896#4245896
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4245896
16 years, 8 months
[JBoss jBPM] - Re: Jbpm-Spring app deployment to jboss Console Server!
by rmoskal
Yes was a very fine answer and it filled with me with hope. I really want to leverage the restful apiprovided by the console server. But things aren't so simple.
Now it seems obvious that the console server needs access to the spring context. Trying to enumerate a list of deployed processes via the restful api in the deault jboss integration causes all kinds of errors related to not finding the spring refrences in the process definition files.
So it seems that there are two paths forward:
I can try to integrate a springified instance of jbpm application server with jboss. Fooling around with the jbpm-service.sar
Or assuming my jpbm application is deployed as a war, I can try to expose the context to gwt-console-server.war, perhaps by changing gwt-console-server-integration.jar.
I know there are also class loading issues, but I think those are all surmountable.
I think getting a springified version of jpbm integrated with the console server would eb tremendously useful integration. I'm sure I could pull it off with a little guidance. I would be happy to write up the solution and share it with others.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4245881#4245881
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4245881
16 years, 8 months