KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > def > Throw


1 package org.jbpm.bpel.def;
2
3 import javax.xml.namespace.QName JavaDoc;
4
5 import org.jbpm.bpel.data.def.VariableDefinition;
6 import org.jbpm.bpel.data.exe.VariableInstance;
7 import org.jbpm.bpel.exe.Fault;
8 import org.jbpm.graph.exe.ExecutionContext;
9
10 /**
11  * The throw activity is used when a business process needs to signal an internal
12  * fault explicitly.
13  * @see "WS-BPEL 2.0 §11.6"
14  * @author Juan Cantú
15  * @version $Revision: 1.5 $ $Date: 2005/06/17 01:31:31 $
16  */

17 public class Throw extends Activity {
18
19   private static final long serialVersionUID = 1L;
20   
21   private QName JavaDoc faultName;
22   private VariableDefinition faultVariable;
23
24   public Throw() {
25   }
26   
27   public Throw(String JavaDoc name) {
28     super(name);
29   }
30
31   public void execute(ExecutionContext context) {
32     Fault fault;
33     
34     if(faultVariable != null) {
35       VariableInstance variableInstance = faultVariable.getInstance(context.getToken());
36       fault = new Fault(faultName, variableInstance.getValue(), faultVariable.getTypeInfo());
37     }
38     else {
39       fault = new Fault(faultName);
40     }
41     
42     this.raiseException(fault, context);
43   }
44   
45   public QName JavaDoc getFaultName() {
46     return faultName;
47   }
48   
49   public void setFaultName(QName JavaDoc faultName) {
50     this.faultName = faultName;
51   }
52   
53   public VariableDefinition getFaultVariable() {
54     return faultVariable;
55   }
56   
57   public void setFaultVariable(VariableDefinition faultVariable) {
58     this.faultVariable = faultVariable;
59   }
60
61   /**{@inheritDoc}*/
62   public void accept(BpelVisitor visitor) {
63     visitor.visit(this);
64   }
65 }
66
Popular Tags