View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.jbpm;
8   
9   import org.jbpm.jpdl.internal.activity.JpdlBinding;
10  import org.jbpm.jpdl.internal.model.JpdlProcessDefinition;
11  import org.jbpm.jpdl.internal.xml.JpdlParser;
12  import org.jbpm.pvm.internal.model.ActivityImpl;
13  import org.jbpm.pvm.internal.util.XmlUtil;
14  import org.jbpm.pvm.internal.xml.Parse;
15  import org.w3c.dom.Element;
16  
17  public class MuleReceiveBinding extends JpdlBinding
18  {
19      public MuleReceiveBinding()
20      {
21          super("mule-receive");
22      }
23  
24      public Object parseJpdl(Element element, Parse parse, JpdlParser parser)
25      {
26          MuleReceiveActivity activity;
27          
28          JpdlProcessDefinition processDefinition = parse.contextStackFind(JpdlProcessDefinition.class);        
29          if (processDefinition.getInitial() == null) 
30          {
31              processDefinition.setInitial(parse.contextStackFind(ActivityImpl.class));          
32              activity = new MuleReceiveActivity(true);
33          } 
34          else
35          {
36              activity = new MuleReceiveActivity(false);
37          }
38  
39          if (element.hasAttribute("var"))
40              activity.setVariableName(XmlUtil.attribute(element, "var", parse));
41          
42          if (element.hasAttribute("endpoint"))
43              activity.setEndpoint(XmlUtil.attribute(element, "endpoint", parse));
44          
45          if (element.hasAttribute("type"))
46              activity.setPayloadClass(XmlUtil.attribute(element, "type", parse));
47  
48          return activity;
49      }
50  }