KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > service > def > CorrelationSetDefinition


1 package org.jbpm.bpel.service.def;
2
3 import java.io.Serializable JavaDoc;
4 import java.util.HashSet JavaDoc;
5 import java.util.Set JavaDoc;
6
7 import org.jbpm.context.exe.ContextInstance;
8 import org.jbpm.graph.exe.Token;
9
10 import org.jbpm.bpel.service.exe.CorrelationSetInstance;
11 import org.jbpm.bpel.wsdl.def.Property;
12
13 /**
14  * Each correlation set is a named group of properties used to identify an
15  * application-level conversation within a process instance.
16  * @see "WS-BPEL 2.0 §10.2"
17  * @author Alejandro Guízar
18  * @version $Revision: 1.5 $ $Date: 2005/05/31 00:49:53 $
19  */

20 public class CorrelationSetDefinition implements Serializable JavaDoc {
21
22   long id;
23   private String JavaDoc name;
24   private Set JavaDoc properties;
25   
26   private static final String JavaDoc CSET_PREFIX = "c_";
27   private static final long serialVersionUID = 1L;
28
29   public String JavaDoc getName() {
30     return name;
31   }
32   
33   public void setName(String JavaDoc name) {
34     this.name = name;
35   }
36   
37   public void addProperty(Property property) {
38     if (properties == null) {
39       properties = new HashSet JavaDoc();
40     }
41     properties.add(property);
42   }
43   
44   public Set JavaDoc getProperties() {
45     return properties;
46   }
47   
48   public void setProperties(Set JavaDoc properties) {
49     this.properties = properties;
50   }
51   
52   public CorrelationSetInstance getInstance(Token token) {
53     ContextInstance context = token.getProcessInstance().getContextInstance();
54     return (CorrelationSetInstance) context.getVariable(CSET_PREFIX + name, token);
55   }
56   
57   public CorrelationSetInstance createInstance(Token token) {
58     CorrelationSetInstance instance = new CorrelationSetInstance();
59     instance.setDefinition(this);
60     ContextInstance context = token.getProcessInstance().getContextInstance();
61     context.createVariable(CSET_PREFIX + name, instance, token);
62     return instance;
63   }
64 }
Popular Tags