KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > Connector > Boot > DCUPComponentManagerConnector


1 /*
2  * DCUPComponentManagerConnector.java
3  *
4  * Created on 5. duben 2002, 13:50
5  */

6
7 package SOFA.Connector.Boot;
8
9 import SOFA.Connector.ConnectorException;
10 import SOFA.Connector.Linkable;
11 import SOFA.Connector.Reference;
12 import SOFA.Connector.RoleBase;
13 import SOFA.Connector.TaggedProfile;
14
15 /**
16  *
17  * @author ghort
18  * @version
19  */

20 public class DCUPComponentManagerConnector implements SOFA.Connector.ECG.Types.CSProcCall {
21
22     /** Creates new DCUPComponentManagerConnector */
23     public DCUPComponentManagerConnector() {
24     }
25
26     static public RoleBase createConnector(SOFA.Connector.ECG.DeploymentDescriptor dd) throws ConnectorException {
27         RoleBase role=null;
28         if (dd.unit.equals("Client")) {
29             role=new SOFA.Connector.Boot.DCUPComponentManagerCRole();
30         } else if (dd.unit.equals("Server")) {
31             role=new SOFA.Connector.Boot.DCUPComponentManagerSRole();
32             role.setDeploymentDescriptor(dd);
33             
34             Linkable skelRMI;
35             String JavaDoc rmiName;
36             try {
37                 rmiName="rmi://"+java.net.InetAddress.getLocalHost().getHostAddress()+":1099/SOFA/Connectors/Boot/DCUPComponentManagerRMISkeleton/"+new java.rmi.server.UID JavaDoc();
38                 skelRMI=new SOFA.Connector.Boot.DCUPComponentManagerRMISkeleton(rmiName);
39             } catch (Exception JavaDoc e) {
40                 throw new ConnectorException("Can't instantiate DCUPComponentManagerRMISkeleton.",e);
41             }
42             skelRMI.link(role);
43
44             Reference ref=new Reference("SOFA.Connector.ECG.SGenerator.Connectors.DCUPComponentManagerConnector",
45                     new TaggedProfile[] { new SOFA.Connector.ECG.Profiles.LocalProfile(role), new SOFA.Connector.ECG.Profiles.RMIProfile(rmiName) } );
46             role.setSOFAReference(ref);
47         } else {
48             throw new ConnectorException("Unknown unit '"+dd.unit+"'.");
49         }
50         return role;
51     }
52   
53   /** Creates server side of connector to CM
54     * @param ddock CM
55     * @param name instance id of the CM
56     * @return server side of connector
57     * @author Petr Hnetynka
58     */

59   public static RoleBase createSrv(SOFA.Component.ComponentManager cm, String JavaDoc id) throws ConnectorException {
60     RoleBase role = new SOFA.Connector.Boot.DCUPComponentManagerSRole();
61     SOFA.Connector.ECG.DeploymentDescriptor cDD = new SOFA.Connector.ECG.DeploymentDescriptor();
62     cDD.unit="Server";
63     role.setDeploymentDescriptor(cDD);
64     
65     Linkable skelRMI;
66     String JavaDoc rmiName;
67     String JavaDoc rmihost = System.getProperty("sofa.rmihost", "localhost");
68     String JavaDoc rmiport = System.getProperty("sofa.rmiport", "1099");
69     try {
70       rmiName="rmi://"+rmihost+":"+rmiport+"/SOFA/Connectors/Boot/DCUPComponentManagerRMISkeleton/"+id;
71       skelRMI = new SOFA.Connector.Boot.DCUPComponentManagerRMISkeleton(id);
72     } catch (Exception JavaDoc e) {
73       throw new ConnectorException("Can't instantiate DCUPComponentManagerRMISkeleton.",e);
74     }
75     skelRMI.link(role);
76
77     // ???
78
Reference ref=new Reference("SOFA.Connector.ECG.SGenerator.Connectors.DCUPComponentManagerConnector",
79     new TaggedProfile[] { new SOFA.Connector.ECG.Profiles.LocalProfile(role), new SOFA.Connector.ECG.Profiles.RMIProfile(rmiName) } );
80     role.setSOFAReference(ref);
81     role.link(cm);
82     return role;
83   }
84   
85   /** Creates client side of connector to CM
86     * @param ref reference to CM
87     * @return client side of connector
88     * @author Petr Hnetynka
89     */

90   public static RoleBase createClt(SOFA.Connector.Reference ref) throws ConnectorException {
91     RoleBase role = new SOFA.Connector.Boot.DCUPComponentManagerCRole();
92     try {
93       role.link(ref);
94     } catch (SOFA.Connector.LinkException e) {
95       throw new ConnectorException("Can't link connector to CM.", e);
96     }
97     return role;
98   }
99
100 }
101
Popular Tags