KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > Made > TIR > Impl > Main


1 /* $Id: Main.java,v 1.2 2004/05/20 14:23:52 bures Exp $ */
2 package SOFA.SOFAnode.Made.TIR.Impl;
3 import java.net.InetAddress JavaDoc;
4 import java.net.UnknownHostException JavaDoc;
5 import java.rmi.Naming JavaDoc;
6 import java.rmi.RMISecurityManager JavaDoc;
7
8 public class Main {
9   
10   /* set path to repository storage in first argument (argv[0]) */
11   public static void main(String JavaDoc[] argv) {
12     // Create and install a security manager
13
if (System.getSecurityManager() == null) {
14       System.setSecurityManager(new RMISecurityManager JavaDoc());
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 JavaDoc rmiport = System.getProperty("sofa.rmiport","1099");
23       String JavaDoc rmihost = System.getProperty("sofa.rmihost","localhost");
24       String JavaDoc sofaNodeName = System.getProperty("sofa.nodename","");
25       
26       if (sofaNodeName.compareTo("")==0) {
27         try {
28           sofaNodeName = InetAddress.getLocalHost().getHostName();
29         } catch (UnknownHostException JavaDoc 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 JavaDoc e) {
42       System.out.println("Exception " + e.getMessage());
43       e.printStackTrace();
44     }
45   }
46   
47 }
48
Popular Tags