KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * InOut2InOutConnector.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.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.InOut.InOut2InOut;
14 import SOFA.Util.VMProperties;
15
16 /** Contains methods for creating a connector between two {@link InOut2InOut} interfaces.
17  *
18  * @author Petr Panuska
19  */

20 public class InOut2InOutConnector {
21   /**
22    * Creates the server side of the connector.
23    * @param inOut InOut which is going to be connectable.
24    * @return the server side of the connector.
25    */

26   public static RoleBase createSrv (InOut2InOut inOut) throws ConnectorException {
27     RoleBase role = new InOut2InOutSRole();
28     SOFA.Connector.ECG.DeploymentDescriptor cDD = new SOFA.Connector.ECG.DeploymentDescriptor();
29     cDD.unit = "Server";
30     role.setDeploymentDescriptor(cDD);
31
32     Linkable skelRMI;
33     String JavaDoc rmiName;
34     String JavaDoc rmihost = System.getProperty(VMProperties.RMI_HOST, "localhost");
35     String JavaDoc rmiport = System.getProperty(VMProperties.RMI_PORT, "1099");
36     String JavaDoc inOutName = System.getProperty(VMProperties.TR_NAME, "localInOut");
37     inOutName = "/SOFA/SOFAnode/InOut/Connector/InOut2InOutRMISkel/" + inOutName;
38     rmiName = "//" + rmihost + ":" + rmiport + inOutName;
39     try {
40       skelRMI = new InOut2InOutRMISkel(inOutName);
41     } catch (Exception JavaDoc e) {
42       throw new ConnectorException("Can't instantiate InOut2InOutRMISkel.\n" + rmiName + "\n", e);
43     }
44     skelRMI.link(role);
45
46     // ???
47
Reference ref = new Reference("SOFA.Connector.ECG.SGenerator.Connectors.DeplDockConnector",
48       new TaggedProfile[]{new SOFA.Connector.ECG.Profiles.LocalProfile(role), new SOFA.Connector.ECG.Profiles.RMIProfile(rmiName)});
49     role.setSOFAReference(ref);
50     role.link(inOut);
51     return role;
52   }
53
54   /**
55    * Creates the client side of the connector.
56    * @param ref the reference to InOut.
57    * @return the client side of the connector.
58    */

59   public static RoleBase createClt (Reference ref) throws ConnectorException {
60     RoleBase role = new SOFA.SOFAnode.InOut.Connector.InOut2InOutCRole();
61     try {
62       role.link(ref);
63     } catch (LinkException e) {
64       throw new ConnectorException("Can't link connector to InOut.\n" + ref + "\n", e);
65     }
66     return role;
67   }
68
69 }
70
Popular Tags