KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > proactive > core > group > ProcessForOneWayCall


1 package org.objectweb.proactive.core.group;
2
3 import org.objectweb.proactive.Body;
4 import org.objectweb.proactive.core.body.LocalBodyStore;
5 import org.objectweb.proactive.core.body.proxy.UniversalBodyProxy;
6 import org.objectweb.proactive.core.mop.MethodCall;
7 import org.objectweb.proactive.core.mop.Proxy;
8 import org.objectweb.proactive.core.mop.StubObject;
9
10 import java.util.Vector JavaDoc;
11
12
13 /**
14  * This class provides multithreading for the oneway methodcall on a group.
15  *
16  * @author Laurent Baduel
17  */

18 public class ProcessForOneWayCall extends AbstractProcessForGroup
19     implements Runnable JavaDoc {
20
21     private int index;
22     private MethodCall mc;
23     private Body body;
24     private ExceptionList exceptionList;
25
26     public ProcessForOneWayCall(ProxyForGroup proxyGroup, Vector JavaDoc memberList,
27         int index, MethodCall mc, Body body, ExceptionList exceptionList) {
28         this.proxyGroup = proxyGroup;
29         this.memberList = memberList;
30         this.index = index;
31         this.mc = mc;
32         this.body = body;
33         this.exceptionList = exceptionList;
34     }
35
36     public synchronized void run() {
37         LocalBodyStore.getInstance().setCurrentThreadBody(body);
38         Object JavaDoc object = this.memberList.get(this.index);
39         boolean objectIsLocal = false;
40
41         /* only do the communication (reify) if the object is not an error nor an exception */
42         if (!(object instanceof Throwable JavaDoc)) {
43             Proxy lastProxy = AbstractProcessForGroup.findLastProxy(object);
44             if (lastProxy instanceof UniversalBodyProxy) {
45                 objectIsLocal = ((UniversalBodyProxy) lastProxy).isLocal();
46             }
47             try {
48                 if (lastProxy == null) {
49                     // means we are dealing with a non-reified object (a standard Java Object)
50
this.mc.execute(object);
51                 } else if (!objectIsLocal) {
52                     ((StubObject) object).getProxy().reify(this.mc);
53                 } else {
54                     ((StubObject) object).getProxy().reify(new MethodCall(
55                             this.mc));
56                 }
57             } catch (Throwable JavaDoc e) {
58                 this.exceptionList.add(new ExceptionInGroup(object, e));
59             }
60         }
61     }
62 }
63
Popular Tags