1 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 20 public class DCUPComponentManagerConnector implements SOFA.Connector.ECG.Types.CSProcCall { 21 22 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 rmiName; 36 try { 37 rmiName="rmi://"+java.net.InetAddress.getLocalHost().getHostAddress()+":1099/SOFA/Connectors/Boot/DCUPComponentManagerRMISkeleton/"+new java.rmi.server.UID (); 38 skelRMI=new SOFA.Connector.Boot.DCUPComponentManagerRMISkeleton(rmiName); 39 } catch (Exception 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 59 public static RoleBase createSrv(SOFA.Component.ComponentManager cm, String 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 rmiName; 67 String rmihost = System.getProperty("sofa.rmihost", "localhost"); 68 String 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 e) { 73 throw new ConnectorException("Can't instantiate DCUPComponentManagerRMISkeleton.",e); 74 } 75 skelRMI.link(role); 76 77 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 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 |