1 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 20 public class TR2InOutConnector { 21 22 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 rmiName = ""; 37 String rmihost = System.getProperty(VMProperties.RMI_HOST, "localhost"); 38 String rmiport = System.getProperty(VMProperties.RMI_PORT, "1099"); 39 String 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 e) { 45 throw new ConnectorException("Can't instantiate TR2InOutRMISkel." + rmiName + "\n", e); 46 } 47 skelRMI.link(role); 48 49 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 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 |