Hi all,
I am always in trouble... sigh...
I have solved the previous stupid problem, but now I have another one.
This is the situation:


  | -------------------------------------- PROCESS DEFINITION 
--------------------------------------
  | 
  | <?xml version="1.0" encoding="UTF-8"?>
  | <process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="Initiator">
  |    <swimlane name="initiator" />
  |    <start-state name="start new process">
  |       <task swimlane="process initiator" />
  |       <transition name="tr1" to="decision">
  |          <action name="action" 
class="com.sample.action.SampleActionHandler">
  |          </action>
  |       </transition>
  |    </start-state>
  |    <decision name="decision">
  |       <handler class="com.sample.decision.SampleDecisionHandler"></handler>
  |       <transition name="tr2" to="action"></transition>
  |       <transition name="tr3" to="end1"></transition>
  |    </decision>
  |    <state name="action">
  |       <transition name="tr4" to="end1"></transition>
  |    </state>
  |    <end-state name="end1"></end-state>
  | </process-definition>
  | ---------------------------------------- MY ACTION HANDLER 
--------------------------------------
  | 
  | 
  | package com.sample.action;
  | 
  | import org.jbpm.graph.def.ActionHandler;
  | import org.jbpm.graph.exe.ExecutionContext;
  | 
  | public class SampleActionHandler implements ActionHandler
  | {
  |     private static final long serialVersionUID = 1L;
  |     public void execute(ExecutionContext context) throws Exception
  |     {
  |         Runtime rt = null;
  |         Process process = null;
  |         
  |         context.getContextInstance().createVariable("greeting", "Greeting 
from SampleActionHandler");
  |         try
  |         {
  |             rt = Runtime.getRuntime();
  |             process = rt.exec("C:\\Applications~1\\ECLIPSE~1\\Start.bat");
  |             context.getContextInstance().createVariable("status", new 
Integer(process.waitFor()));
  |         }
  |         catch (Exception e)
  |         {
  |             System.out.println(e);
  |             context.getContextInstance().createVariable("budget", new 
Integer(1));
  |         }
  |     }
  | }
  | 
  | 
  | ------------------------------------- MY DECISION HANDLER 
--------------------------------------
  | 
  | 
  | package com.sample.decision;
  | 
  | import org.jbpm.graph.exe.ExecutionContext;
  | import org.jbpm.graph.node.DecisionHandler;
  | 
  | public class SampleDecisionHandler implements DecisionHandler
  | {
  |     private static final long serialVersionUID = 1L;
  |     public String decide(ExecutionContext context) throws Exception
  |     {
  |         int budget = 
((Number)context.getContextInstance().getVariable("status")).intValue();
  |         if (budget == 0) return "tr2";
  |         else if (budget == 1) return "tr3";
  |         else return "tr3";
  |     }
  | }
  | 
  | 
  | ---------------------------------------- MY NEW CLASS 
----------------------------------------
  | 
  | 
  | package com.sample.util;
  | 
  | import org.jbpm.graph.def.ProcessDefinition;
  | import org.jbpm.graph.exe.ProcessInstance;
  | 
  | public class StartProcess
  | {
  |     private String path = "";
  |     
  |     /** Creates a new instance of StartProcess */
  |     private StartProcess()
  |     {
  |         path = "C:\\Applications and Projects\\ECLIPSE Workspace\\Process 
Initiator\\src\\" +
  |                "process\\Initiator.par\\processdefinition.xml";
  |     }
  |     
  |     
  |     /** */
  |     public void init()
  |     {
  |         try
  |         {
  |             ProcessDefinition def = 
ProcessDefinition.parseXmlResource(path);
  |             System.out.println("STEP 1 - Istanziata la classe 
ProcessDefinition");
  |             
  |             ProcessInstance instance = new ProcessInstance(def);
  |             System.out.println("STEP 2 - Istanziata la classe 
ProcessInstance");
  |             
  |             instance.signal();
  |             System.out.println("STEP 3 - Effettuato il primo signal");
  |         }
  |         catch(Exception e)
  |         {
  |             System.err.println(e.getMessage());
  |             //e.printStackTrace();
  |         }
  |     }
  |     
  |     
  |     /** */
  |     public static void main(String[] args)
  |     {
  |         try
  |         {
  |             StartProcess sp = new StartProcess();
  |             System.out.println("STEP 0 - Istanziata la classe 
StartProcess");
  |             System.out.println(sp.path);
  |             sp.init();
  |         }
  |         catch(Exception exc)
  |         {
  |             System.err.println(exc.getMessage());
  |             exc.printStackTrace();
  |         }
  |     }
  | }
  | 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3935443#3935443

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3935443


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to