KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > data > def > VariableDefinition


1 package org.jbpm.bpel.data.def;
2
3 import java.io.Serializable JavaDoc;
4
5 import org.jbpm.context.exe.ContextInstance;
6 import org.jbpm.graph.exe.Token;
7
8 import org.jbpm.bpel.data.exe.VariableInstance;
9
10 /**
11  * Variables provide the means for holding messages that are exchanged,
12  * as well as intermediate data used in business logic and in composing
13  * messages sent to partners.
14  * @see "WS-BPEL 2.0 §9.2"
15  * @author Alejandro Guízar
16  * @version $Revision: 1.6 $ $Date: 2005/05/31 00:49:52 $
17  */

18 public class VariableDefinition implements Serializable JavaDoc {
19
20   long id;
21   private String JavaDoc name;
22   private VariableTypeInfo typeInfo;
23   
24   private static final long serialVersionUID = 1L;
25   
26   public VariableDefinition() {
27   }
28   
29   public VariableDefinition(String JavaDoc name) {
30     this.name = name;
31   }
32   
33   public String JavaDoc getName() {
34     return name;
35   }
36   
37   public void setName(String JavaDoc name) {
38     this.name = name;
39   }
40   
41   public VariableTypeInfo getTypeInfo() {
42     return typeInfo;
43   }
44   
45   public void setTypeInfo(VariableTypeInfo type) {
46     this.typeInfo = type;
47   }
48
49   /**
50    * Creates an instance of this variable in the scope of the given token.
51    * @param token
52    * @return the created instance
53    */

54   public VariableInstance createInstance(Token token) {
55     VariableInstance instance = typeInfo.createVariableInstance();
56     instance.setDefinition(this);
57     ContextInstance contextInstance = token.getProcessInstance().getContextInstance();
58     contextInstance.createVariable(name, instance, token);
59     return instance;
60   }
61   
62   /**
63    * Gets the instance of this variable in the scope of the given token.
64    * @param token
65    * @return the instance in place
66    */

67   public VariableInstance getInstance(Token token) {
68     ContextInstance context = token.getProcessInstance().getContextInstance();
69     return (VariableInstance) context.getVariable(name, token);
70   }
71 }
72
Popular Tags