KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jbpm.bpel.def;
2
3 import java.io.Serializable JavaDoc;
4 import java.util.List JavaDoc;
5
6 import org.jbpm.graph.exe.ExecutionContext;
7 import org.jbpm.graph.exe.Token;
8
9 /**
10  * The assign activity is used to copy data from one variable to another,
11  * as well as to construct and insert new data using expressions.
12  * @see "WS-BPEL 2.0 §9.3"
13  * @author Alejandro Guízar
14  * @version $Revision: 1.3 $ $Date: 2005/05/31 00:49:53 $
15  */

16 public class Assign extends Activity {
17   
18   private static final long serialVersionUID = 1L;
19   
20   private List JavaDoc copies;
21
22   public Assign() {
23     super();
24   }
25   
26   public Assign(String JavaDoc name) {
27     super(name);
28   }
29
30   public void execute(ExecutionContext context) {
31     Token token = context.getToken();
32     
33     for (int i = 0, n = copies.size(); i < n; i++) {
34       ((Copy) copies.get(i)).copyValue(token);
35     }
36     leave(context);
37   }
38   
39   public List JavaDoc getCopies() {
40     return copies;
41   }
42   
43   public void setCopies(List JavaDoc copies) {
44     this.copies = copies;
45   }
46   
47   public static class Copy implements Serializable JavaDoc {
48
49     private static final long serialVersionUID = 1L;
50     
51     long id;
52     private From from;
53     private To to;
54     
55     public From getFrom() {
56       return from;
57     }
58     
59     public void setFrom(From from) {
60       this.from = from;
61     }
62     
63     public To getTo() {
64       return to;
65     }
66     
67     public void setTo(To to) {
68       this.to = to;
69     }
70     
71     public void copyValue(Token token) {
72       to.assign(token, from.extract(token));
73     }
74   }
75   
76   public static abstract class From implements Serializable JavaDoc {
77     
78     long id;
79     
80     public abstract Object JavaDoc extract(Token token);
81   }
82   
83   public static abstract class To implements Serializable JavaDoc {
84     
85     long id;
86     
87     public abstract void assign(Token token, Object JavaDoc value);
88   }
89
90   /**{@inheritDoc}*/
91   public void accept(BpelVisitor visitor) {
92     visitor.visit(this);
93   }
94 }
95
Popular Tags