KickJava   Java API By Example, From Geeks To Geeks.

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


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

5 package SOFA.SOFAnode.TR.Connector;
6
7 import SOFA.Connector.ConnectorException;
8 import SOFA.Connector.LinkException;
9 import SOFA.Connector.Linkable;
10 import SOFA.Connector.Reference;
11 import SOFA.Connector.RoleBase;
12 import SOFA.Connector.TaggedProfile;
13 import SOFA.SOFAnode.TR.TR2InOut;
14 import SOFA.Util.VMProperties;
15
16 /** Contains methods for creating a connector between TR and InOut interfaces.
17  *
18  * @author Petr Panuska
19  */

20 public class TR2InOutConnector {
21
22   /**
23    * Creates the server side of a connector between {@link SOFA.SOFAnode.TR.Impl.TRImpl TR}
24    * and {@link SOFA.SOFAnode.InOut.Impl.InOutImpl InOut}. The connector is defined in
25    * the {@link TR2InOut} interface.
26    * @param tr TR which is going to be connectable.
27    * @return the server side of the connector.
28    */

29   public static RoleBase createSrv (TR2InOut tr) throws ConnectorException {
30     RoleBase role = new TR2InOutSRole();
31     SOFA.Connector.ECG.DeploymentDescriptor cDD = new SOFA.Connector.ECG.DeploymentDescriptor();
32     cDD.unit = "Server";
33     role.setDeploymentDescriptor(cDD);
34
35     Linkable skelRMI;
36     String JavaDoc rmiName = "";
37     String JavaDoc rmihost = System.getProperty(VMProperties.RMI_HOST, "localhost");
38     String JavaDoc rmiport = System.getProperty(VMProperties.RMI_PORT, "1099");
39     String JavaDoc trName = System.getProperty(VMProperties.TR_NAME, "localTR");
40     trName = "/SOFA/SOFAnode/TR/Connector/TR2InOutRMISkel/" + trName;
41     try {
42       rmiName = "//" + rmihost + ":" + rmiport + trName;
43       skelRMI = new TR2InOutRMISkel(trName);
44     } catch (Exception JavaDoc e) {
45       throw new ConnectorException("Can't instantiate TR2InOutRMISkel." + rmiName + "\n", e);
46     }
47     skelRMI.link(role);
48
49     // ???
50
Reference ref = new Reference("SOFA.Connector.ECG.SGenerator.Connectors.DeplDockConnector",
51       new TaggedProfile[]{new SOFA.Connector.ECG.Profiles.LocalProfile(role), new SOFA.Connector.ECG.Profiles.RMIProfile(rmiName)});
52     role.setSOFAReference(ref);
53     role.link(tr);
54     return role;
55   }
56
57   /**
58    * Creates the client side of a connector between {@link SOFA.SOFAnode.TR.Impl.TRImpl TR}
59    * and {@link SOFA.SOFAnode.InOut.Impl.InOutImpl InOut}. The connector is defined in
60    * the {@link TR2InOut} interface.
61    * @param ref the reference to TR.
62    * @return the client side of the connector.
63    */

64   public static RoleBase createClt (Reference ref) throws ConnectorException {
65     RoleBase role = new SOFA.SOFAnode.TR.Connector.TR2InOutCRole();
66     try {
67       role.link(ref);
68     } catch (LinkException e) {
69       throw new ConnectorException("Can't link connector to TR.\n" + ref + "\n", e);
70     }
71     return role;
72   }
73 }
74
Popular Tags