1 2 package SOFA.SOFAnode.Made.TIR.Impl; 3 import java.net.InetAddress ; 4 import java.net.UnknownHostException ; 5 import java.rmi.Naming ; 6 import java.rmi.RMISecurityManager ; 7 8 public class Main { 9 10 11 public static void main(String [] argv) { 12 if (System.getSecurityManager() == null) { 14 System.setSecurityManager(new RMISecurityManager ()); 15 } 16 17 try { 18 if (argv.length==0) { 19 System.err.println("Set directory with repository to the first argument."); 20 System.exit(1); 21 } 22 String rmiport = System.getProperty("sofa.rmiport","1099"); 23 String rmihost = System.getProperty("sofa.rmihost","localhost"); 24 String sofaNodeName = System.getProperty("sofa.nodename",""); 25 26 if (sofaNodeName.compareTo("")==0) { 27 try { 28 sofaNodeName = InetAddress.getLocalHost().getHostName(); 29 } catch (UnknownHostException e) { 30 System.err.println("Can't get host name. Set name to property \"sofa.nodename\""); 31 System.exit(1); 32 } 33 } 34 35 System.setProperty("sofa.nodename",sofaNodeName); 36 37 RepositoryImpl repository = new RepositoryImpl(argv[0],sofaNodeName); 38 Naming.rebind("//"+rmihost+":"+rmiport+"/Repository", repository); 39 40 System.out.println("Repository bound in registry"); 41 } catch (Exception e) { 42 System.out.println("Exception " + e.getMessage()); 43 e.printStackTrace(); 44 } 45 } 46 47 } 48 | Popular Tags |