KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > xml > ThrowReader


1 package org.jbpm.bpel.xml;
2
3 import javax.xml.namespace.QName JavaDoc;
4
5 import org.w3c.dom.Element JavaDoc;
6
7 import org.jbpm.bpel.data.def.VariableDefinition;
8 import org.jbpm.bpel.def.Activity;
9 import org.jbpm.bpel.def.Throw;
10 import org.jbpm.bpel.xml.util.NodeUtil;
11 import org.jbpm.jpdl.xml.Problem;
12
13 /**
14  * @author Juan Cantú
15  * @version $Revision: 1.6 $ $Date: 2005/06/23 20:45:04 $
16  */

17 public class ThrowReader extends ActivityReader {
18
19   protected Activity createActivity() {
20     return new Throw();
21   }
22   
23   protected void readActivity(Activity activity, Element JavaDoc activityElem) {
24     Throw throwActivity = (Throw) activity;
25     
26     String JavaDoc faultNameString = NodeUtil.getAttribute(activityElem, BpelConstants.ATTR_FAULT_NAME);
27     if( faultNameString == null ) {
28       bpelReader.getProblemHandler().add(
29           new LocalizedProblem(Problem.LEVEL_ERROR, "fault name is missing", activityElem));
30     }
31     else {
32       QName JavaDoc faultName = NodeUtil.getQName(faultNameString, activityElem);
33       throwActivity.setFaultName( faultName );
34     }
35     
36     String JavaDoc variableName = NodeUtil.getAttribute(activityElem, BpelConstants.ATTR_FAULT_VARIABLE);
37     if( variableName != null ) {
38       VariableDefinition faultVariable = throwActivity.getCompositeActivity().findVariable(variableName);
39       if(faultVariable == null) {
40         bpelReader.getProblemHandler().add(
41             new LocalizedProblem(Problem.LEVEL_ERROR, "variable not found", activityElem));
42       }
43       else {
44         throwActivity.setFaultVariable(faultVariable);
45       }
46     }
47   }
48 }
49
Popular Tags