KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > TR > Connector > TR2InOutCRole


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

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

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