KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > TR > Impl > Main


1 /**
2  * Main.java is a part of the SOFA project.
3  * This file was created by pepan on 20.3.2003.
4  */

5 package SOFA.SOFAnode.TR.Impl;
6
7 import java.net.InetAddress JavaDoc;
8 import java.net.UnknownHostException JavaDoc;
9 import java.rmi.RMISecurityManager JavaDoc;
10
11 import SOFA.Connector.Reference;
12 import SOFA.SOFAnode.InOut.Impl.Browser;
13 import SOFA.SOFAnode.TR.Connector.TR2InOutConnector;
14 import SOFA.Util.VMProperties;
15
16 /**
17  * Runs TR, InOut and possibly the graphical client.
18  * @author Petr Panuska
19  */

20 public class Main {
21
22   /**
23    * Runs TR, InOut and possibly the client. The client is started only in the case when
24    * a parameter on the command line is provided.
25    * @param argv the single argument is a path to a client configuration file.
26    * The configuration file is a a text file listing all known (remote/local) SOFA nodes.
27    * Every line consists of a key and a value (key=value[new line]), the key is a name
28    * of the SOFA node as it appears in the client, the value is a string form of
29    * a connector pointing to the InOut part (InOut2Client connector) of the SOFA node.
30    */

31   public static void main (String JavaDoc[] argv) {
32
33     if (System.getSecurityManager() == null) {
34       System.setSecurityManager(new RMISecurityManager JavaDoc());
35     }
36     String JavaDoc trDir = System.getProperty(VMProperties.TR_DIR, null);
37     if (trDir == null) {
38       System.out.println("The property '" + VMProperties.TR_DIR + "' has not been specified.");
39       System.exit(1);
40     }
41     try {
42       String JavaDoc sofaNodeName = System.getProperty(VMProperties.NODE_NAME);
43
44       if (sofaNodeName == null) {
45         try {
46           sofaNodeName = InetAddress.getLocalHost().getHostName();
47         } catch (UnknownHostException JavaDoc e) {
48           System.err.println("Can't get the host name.\nSet the name to the property '" + VMProperties.NODE_NAME + "' when TR is being started.");
49           System.exit(1);
50         }
51       }
52
53       System.setProperty(VMProperties.NODE_NAME, sofaNodeName);
54
55       TRImpl tr = new TRImpl(trDir);
56
57       System.out.print("Registering TR....");
58       Reference refTR = TR2InOutConnector.createSrv(tr).getSOFAReference();
59       System.out.println("OK");
60       System.out.println(refTR);
61
62       SOFA.SOFAnode.InOut.Impl.Main.runInOut(refTR, null); // run InOut server in the same address space
63

64     } catch (Exception JavaDoc e) {
65       System.out.println("Exception " + e.getMessage());
66       e.printStackTrace();
67     }
68     if (argv.length == 1) {
69       new Browser(argv[0]);
70     } else
71       System.out.println("Running without client!!\n");
72   }
73 }
74
Popular Tags