1 5 package SOFA.SOFAnode.InOut.Impl; 6 7 import java.net.InetAddress ; 8 import java.net.UnknownHostException ; 9 import java.rmi.RMISecurityManager ; 10 11 import SOFA.Connector.ConnectorException; 12 import SOFA.Connector.Reference; 13 import SOFA.SOFAnode.InOut.Connector.InOut2ClientConnector; 14 import SOFA.SOFAnode.InOut.Connector.InOut2InOutConnector; 15 import SOFA.Util.VMProperties; 16 17 23 public class Main { 24 25 32 public static void main (String [] argv) { 33 if (System.getSecurityManager() == null) { 34 System.setSecurityManager(new RMISecurityManager ()); 35 } 36 String rmiHost = System.getProperty(VMProperties.RMI_HOST, "localhost"); 37 String rmiPort = System.getProperty(VMProperties.RMI_PORT, "1099"); 38 String trName = System.getProperty(VMProperties.TR_NAME, "localTR"); 39 runInOut(null, "SOFA.Connector.ECG.SGenerator.Connectors.DeplDockConnector-RMI;//" 40 + rmiHost + ":" + rmiPort + "/SOFA/SOFAnode/TR/Connector/TR2InOutRMISkel/" + trName + "-"); 41 } 42 43 51 public static void runInOut (Reference trRef, String referenceString) { 52 try { 53 InOutImpl inOut = null; 54 if (trRef == null) { 55 String sofaNodeName = System.getProperty(VMProperties.NODE_NAME); 56 57 if (sofaNodeName == null) { 58 try { 59 sofaNodeName = InetAddress.getLocalHost().getHostName(); 60 } catch (UnknownHostException e) { 61 System.err.println("Can't get the host name.\nSet the name to the property '" + VMProperties.NODE_NAME + "' when TR is being started."); 62 System.exit(1); 63 } 64 } 65 66 System.setProperty(VMProperties.NODE_NAME, sofaNodeName); 67 68 inOut = new InOutImpl(Reference.fromString(referenceString)); 69 } else 70 inOut = new InOutImpl(trRef); 71 72 System.out.print("Registering InOut2Client...."); 73 Reference refInOut = InOut2ClientConnector.createSrv(inOut).getSOFAReference(); 74 System.out.println("OK"); 75 System.out.println(refInOut); 76 77 System.out.print("Registering InOut2InOut...."); 78 refInOut = InOut2InOutConnector.createSrv(inOut).getSOFAReference(); 79 System.out.println("OK"); 80 System.out.println(refInOut); 81 82 } catch (ConnectorException e) { 83 System.out.println("Exception " + e.getMessage()); 84 e.printStackTrace(); 85 } 86 115 } 116 } 117 | Popular Tags |