KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > InOut > Connector > InOut2InOutCRole


1 /**
2  * InOut2InOutCRole.java is a part of the SOFA project.
3  * This file was created by pepan on 18.4.2003.
4  */

5 package SOFA.SOFAnode.InOut.Connector;
6
7 import SOFA.Connector.LinkException;
8 import SOFA.Connector.Reference;
9 import SOFA.Connector.RoleBaseImpl;
10 import SOFA.Connector.TaggedProfile;
11 import SOFA.SOFAnode.InOut.Bundle;
12 import SOFA.SOFAnode.InOut.InOut2InOut;
13 import SOFA.SOFAnode.InOut.InOutException;
14 import SOFA.SOFAnode.TR.ComponentInfo;
15
16 /**
17  *
18  * @author Petr Panuska
19  */

20 public class InOut2InOutCRole extends RoleBaseImpl implements InOut2InOut {
21   protected CNInOut2InOut target;
22
23   public void link (Object JavaDoc target) throws LinkException {
24     try {
25       if (target instanceof Reference) {
26         Reference ref = (Reference) target;
27         setSOFAReference(ref);
28         TaggedProfile[] profiles = ref.profiles;
29         for (int i = 0; i < profiles.length; i++) {
30           if (profiles[i].tag.equals("LOCAL")) {
31             this.target = (CNInOut2InOut) ((SOFA.Connector.ECG.Profiles.LocalProfile) profiles[i]).link;
32             return;
33           } else if (profiles[i].tag.equals("RMI")) {
34             this.target = new InOut2InOutRMIStub(((SOFA.Connector.ECG.Profiles.RMIProfile) profiles[i]).URL);
35             return;
36           }
37         }
38       } else {
39         this.target = (CNInOut2InOut) target;
40       }
41     } catch (Exception JavaDoc e) {
42       throw new LinkException("Can't link InOut2InOutCRole. ", e);
43     }
44   }
45
46   public Bundle pullBundle (ComponentInfo[] descs, ComponentInfo[] comps, boolean inferiors) throws InOutException {
47     return target.pullBundle(descs, comps, inferiors);
48   }
49
50   public void pushBundle (Bundle bundle) throws InOutException {
51     target.pushBundle(bundle);
52   }
53 }
54
Popular Tags