[jboss-user] [jBPM] - Re: JBPM5 Implementation

Donald Walters do-not-reply at jboss.com
Wed Aug 3 14:08:18 EDT 2011


Donald Walters [http://community.jboss.org/people/dondragon2] created the discussion

"Re: JBPM5 Implementation"

To view the discussion, visit: http://community.jboss.org/message/619233#619233

--------------------------------------------------------------
Thanks Guys. I was able to make something work based on the answers above. It may not be as clean as it aught to be it is similar to what I have in the JBPM4.

Basically i created a dummy interface... This is just so that the BPMN2 xml won't scream  :) 

<itemDefinition id="_2_InMessageType" structureRef="java.lang.String"/>
    <message id="_2_InMessage" itemRef="_2_InMessageType"/>
    <interface id="_2_ServiceInterface" name="com.core.DummyService">
        <operation id="_2_ServiceOperation" name="handle">
            <inMessageRef>_2_InMessage</inMessageRef>
        </operation>
    </interface>

...

<serviceTask id="prompt6" name="prompt6" operationRef="_2_ServiceOperation" implementation="Other">
            <ioSpecification>
                <dataInput id="prompt6_type" name="type"/>
                <dataInput id="prompt6_processItem" name="processItem"/>
                <dataInput id="prompt6_message" name="message"/>
                <dataOutput id="prompt6_result" name="processItem"/>
                <inputSet>
                    <dataInputRefs>prompt6_type</dataInputRefs>
                    <dataInputRefs>prompt6_processItem</dataInputRefs>
                    <dataInputRefs>prompt6_message</dataInputRefs>
                </inputSet>
                <outputSet>
                    <dataOutputRefs>prompt6_result</dataOutputRefs>
                </outputSet>
            </ioSpecification>
            <dataInputAssociation>
                <targetRef>prompt6_message</targetRef>
                <assignment>
                    <from xsi:type="tFormalExpression">Hello World!!</from>
                    <to xsi:type="tFormalExpression">prompt6_message</to>
                </assignment>
            </dataInputAssociation>
            <dataInputAssociation>
                <targetRef>prompt6_type</targetRef>
                <assignment>
                    <from xsi:type="tFormalExpression">com.core.test.Prompt</from>
                    <to xsi:type="tFormalExpression">prompt6_type</to>
                </assignment>
            </dataInputAssociation>
            <dataInputAssociation>
                <sourceRef>processItem</sourceRef>
                <targetRef>prompt6_processItem</targetRef>
            </dataInputAssociation>
            <dataOutputAssociation>
                <sourceRef>prompt6_result</sourceRef>
                <targetRef>processItem</targetRef>
            </dataOutputAssociation>
        </serviceTask>



Then I created a handler and register it for the Service Task. This will take the process type parameter and create the necessary class.

 @Override
    public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
        String className = (String) workItem.getParameter("processType");
        try {
            Class clazz = Class.forName(className);


            Constructor constructor = clazz.getConstructor(Map.class);


            ProcessItem processItem = (ProcessItem)workItem.getParameter("processItem");
            Map params = workItem.getParameters();
            params.remove("Interface");
            params.remove("Operation");
            params.remove("ParameterType");
            params.remove("processItem");


            GenericProcess process =(GenericProcess) constructor.newInstance(params);

            Object result = process.execute(processItem);
            Map<String, Object> results = new HashMap<String, Object>();
            results.put("processItem", result);
        System.out.println("=================================\n");
            manager.completeWorkItem(workItem.getId(), results);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }

Also, I used the timer event to do the state with <on event="timer>

<intermediateCatchEvent id="wait4" name="wait4">
            <timerEventDefinition>
                <timeDuration>180000</timeDuration>
            </timerEventDefinition>
        </intermediateCatchEvent>

But I have 1 issue with that. The timer application does not exist after the time is expired. I think it is still there waiting. (not sure on this)

Also, how do I get the activity (node id) in order to cancel the timer?
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/619233#619233]

Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110803/76e17468/attachment-0001.html 


More information about the jboss-user mailing list