KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jbpm.bpel.def;
2
3 import org.w3c.dom.Element JavaDoc;
4
5 import org.jbpm.graph.exe.ExecutionContext;
6 import org.jbpm.graph.exe.Token;
7
8 import org.jbpm.bpel.service.def.Receiver;
9 import org.jbpm.bpel.service.def.InboundMessageActivity;
10
11 /**
12  * A business process provides services to its partners through receive activities.
13  * @see "WS-BPEL 2.0 §11.4"
14  * @author Juan Cantú
15  * @version $Revision: 1.6 $ $Date: 2005/05/31 00:49:53 $
16  */

17 public class Receive extends Activity implements InboundMessageActivity {
18
19   private static final long serialVersionUID = 1L;
20
21   private boolean createInstance;
22   private Receiver receiver;
23   
24   public Receive() {
25   }
26
27   public Receive(String JavaDoc name) {
28     super(name);
29   }
30
31   public void execute(ExecutionContext context) {
32     receiver.receive( context.getToken() );
33   }
34
35   public void messageReceived(Receiver receiver, Element JavaDoc element, Token token) {
36     if (this != token.getNode()) {
37       throw new AssertionError JavaDoc("token must be located at receive: " +
38           "token=" + token + ", node=" + token.getNode());
39     }
40     receiver.readMessage(element, token);
41     receiver.close(token);
42     leave(new ExecutionContext(token));
43   }
44   
45   public Receiver getReceiver() {
46     return receiver;
47   }
48   
49   //test method
50
public void setReceiver(Receiver receiver) {
51     this.receiver = receiver;
52   }
53
54   public boolean isCreateInstance() {
55     return createInstance;
56   }
57   
58   public void setCreateInstance(boolean createInstance) {
59     this.createInstance = createInstance;
60   }
61
62   /**{@inheritDoc}*/
63   public void accept(BpelVisitor visitor) {
64     visitor.visit(this);
65   }
66 }
Popular Tags