View Javadoc

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