1 2 package SOFA.SOFAnode.Run; 3 4 import java.net.InetAddress ; 5 import java.net.UnknownHostException ; 6 import java.rmi.Naming ; 7 import java.rmi.RMISecurityManager ; 8 9 import SOFA.SOFAnode.Made.TIR.Impl.RepositoryImpl; 10 import SOFA.SOFAnode.Run.CCNS.ConnectorCacheNSImpl; 11 12 public class RunTIRAndCCNS { 13 14 19 public static void main(String [] argv) { 20 if (System.getSecurityManager() == null) { 21 System.setSecurityManager(new RMISecurityManager ()); 22 } 23 24 try { 25 if (argv.length==0) { 26 System.err.println("Set directory with repository to the first argument."); 27 System.exit(1); 28 } 29 String rmiport = System.getProperty("sofa.rmiport","1099"); 30 String rmihost = System.getProperty("sofa.rmihost","localhost"); 31 String sofaNodeName = System.getProperty("sofa.nodename",""); 32 33 if (sofaNodeName.compareTo("")==0) { 34 try { 35 sofaNodeName = InetAddress.getLocalHost().getHostName(); 36 } catch (UnknownHostException e) { 37 System.err.println("Can't get host name. Set name to property \"sofa.nodename\""); 38 System.exit(1); 39 } 40 } 41 42 System.setProperty("sofa.nodename",sofaNodeName); 43 44 RepositoryImpl repository = new RepositoryImpl(argv[0],sofaNodeName); 45 System.out.print("Registering TIR...."); 46 Naming.rebind("//"+rmihost+":"+rmiport+"/Repository", repository); 47 System.out.println("OK"); 48 49 System.out.print("Starting CCNS...."); 50 ConnectorCacheNSImpl ccns = new ConnectorCacheNSImpl(); 51 System.out.println("OK"); 52 System.out.print("Registering CCNS...."); 53 Naming.rebind("//"+rmihost+":"+rmiport+"/CCNS", ccns); 54 System.out.println("OK"); 55 56 } catch (Exception e) { 57 System.out.println("Exception " + e.getMessage()); 58 e.printStackTrace(); 59 } 60 61 } 62 } 63 | Popular Tags |