KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > Run > RunTIRAndCCNS


1 /* $Id: RunTIRAndCCNS.java,v 1.2 2004/05/20 14:23:52 bures Exp $ */
2 package SOFA.SOFAnode.Run;
3
4 import java.net.InetAddress JavaDoc;
5 import java.net.UnknownHostException JavaDoc;
6 import java.rmi.Naming JavaDoc;
7 import java.rmi.RMISecurityManager JavaDoc;
8
9 import SOFA.SOFAnode.Made.TIR.Impl.RepositoryImpl;
10 import SOFA.SOFAnode.Run.CCNS.ConnectorCacheNSImpl;
11
12 public class RunTIRAndCCNS {
13
14   /** Runs both TIR and CCNS. The used java properties is: sofa.rmiport, sofa.rmihost,
15     * sofa.nodename, sofa.connector.ccns
16     *
17     * @param argv
18     */

19   public static void main(String JavaDoc[] argv) {
20     if (System.getSecurityManager() == null) {
21       System.setSecurityManager(new RMISecurityManager JavaDoc());
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 JavaDoc rmiport = System.getProperty("sofa.rmiport","1099");
30       String JavaDoc rmihost = System.getProperty("sofa.rmihost","localhost");
31       String JavaDoc sofaNodeName = System.getProperty("sofa.nodename","");
32       
33       if (sofaNodeName.compareTo("")==0) {
34         try {
35           sofaNodeName = InetAddress.getLocalHost().getHostName();
36         } catch (UnknownHostException JavaDoc 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 JavaDoc e) {
57       System.out.println("Exception " + e.getMessage());
58       e.printStackTrace();
59     }
60
61   }
62 }
63
Popular Tags