KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * InOut2ClientConnector.java is a part of the SOFA project.
3  * This file was created by pepan on 16.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.InOut2Client;
14 import SOFA.Util.VMProperties;
15
16 /** Contains methods for creating a connector between the
17  * {@link SOFA.SOFAnode.InOut.Impl.Browser client implementation} and the {@link InOut2Client} interface.
18  *
19  * @author Petr Panuska
20  */

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

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

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