ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/core/Core.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/core/Core.java (file contents):
Revision 1.1 by ajm, Wed Nov 8 21:24:33 2000 UTC vs.
Revision 1.10 by ajm, Thu Nov 16 19:28:03 2000 UTC

# Line 1 | Line 1
1   //---PACKAGE DECLARATION---
2  
3   //---IMPORTS---
4 < import core.*;
4 > import uk.ac.ukc.iscream.core.*;
5   import org.omg.CORBA.*;
6   import org.omg.CosNaming.*;
7   import org.omg.PortableServer.*;
8 + import java.util.*;
9 + import java.io.*;
10  
11   /**
12   * The main class for the CORE of the I-Scream system.
# Line 26 | Line 28 | class Core {
28       */
29      public static final String REVISION = "$Revision$";
30      
31 +    /**
32 +     * The toString() of this class
33 +     * As it won't be instatiated, this is needed.
34 +     */
35 +    public static final String toString = "CORE(" + REVISION.substring(11, REVISION.length() - 2) + ")";
36 +    
37 +    /**
38 +     * The default location of the properties file for the system
39 +     */
40 +    public static final String DEFAULTPROPERTIES = "default.properties";
41 +    
42   //---STATIC METHODS---
43  
44      /**
# Line 36 | Line 49 | class Core {
49       * @param args the command line arguments
50       */
51      public static void main(String[] args) {
52 <        System.out.println("I-Scream CORE:" + REVISION + " - coming up.");
52 >        System.out.println("--- I-Scream ---");
53 >                
54 >        // get the command line args
55 >        String defaultProperties = DEFAULTPROPERTIES;
56 >        if (args.length > 0) {
57 >            if (args[0].equals("-l")) {
58 >                defaultProperties = args[1];
59 >            } else if (args[0].equals("-h")) {
60 >                usage();
61 >            } else {
62 >                usage();
63 >            }            
64 >        }
65 >
66 >        // load the default properties file into the system properties
67 >        System.out.println(toString + ": initialising - using " + defaultProperties);
68          try {
69 +            Properties initProperties = new Properties(System.getProperties());
70 +            initProperties.load(new FileInputStream(new File(defaultProperties)));
71 +            System.setProperties(initProperties);
72 +
73 +
74 +        } catch (Exception e) {
75 +            System.err.println(toString + ": ERROR " + e.getMessage());
76 +            usage();
77 +        }
78 +
79 +        // continue to bring the system up
80 +        System.out.println(toString + ": coming up");        
81 +        try {
82              // start the ORB
83              ORB orb = ORB.init(args, null);
84              
# Line 49 | Line 90 | class Core {
90              objRef = orb.resolve_initial_references("NameService");
91              NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
92              
93 <            // get a ref to our servers
94 <            // first the Configurator
95 <            ConfiguratorServant configuratorRef = new ConfiguratorServant(poa);
93 >            // start and bind each server in turn
94 >
95 >            // create the logger (either Screen or File)
96 >            ScreenLoggerServant loggerRef = new ScreenLoggerServant(Integer.parseInt(System.getProperty("uk.ac.ukc.iscream.Verbosity")));
97 >            //FileLoggerServant loggerRef = new FileLoggerServant("core.log");
98 >            // and advertise it to the naming context
99 >            objRef = poa.servant_to_reference(loggerRef);
100 >            ncRef.bind(ncRef.to_name("iscream.Logger"), objRef);
101              
102 <            // then the logger
103 <            // **** PUT THE LOGGER HERE TIM ****
102 >            // get a ref to the logger servant as a Logger reference
103 >            Logger logRef = LoggerHelper.narrow(objRef);
104              
105 <            // advertise them to the naming context
106 <            // Configurator
105 >            // create the Configurator
106 >            ConfiguratorServant configuratorRef = new ConfiguratorServant(System.getProperty("uk.ac.ukc.iscream.ConfigurationLocation"), poa, logRef);
107 >            
108 >            // and advertise it to the naming context
109              objRef = poa.servant_to_reference(configuratorRef);
110              ncRef.bind(ncRef.to_name("iscream.Configurator"), objRef);
111              
64            // Logger
65            // **** REGISTER THE LOGGER WITH THE NAME SERVICE TIM ****
66            
112              // start the POA off
113 <            poa.the_POAManager().activate();            
113 >            poa.the_POAManager().activate();
114 >                        
115 >            logRef.write(toString, Logger.SYSINIT, "started");
116              
70            
71            System.out.println("I-Scream CORE:" + REVISION + " - started.");
72            
117              // now we are running, we just need to serve
118              // so we ask the orb to block for us until it has finished
119              orb.run();
# Line 88 | Line 132 | class Core {
132                  e.printStackTrace(System.out);
133              }
134          }
135 +    }
136 +    
137 +    /**
138 +     * A simple method to print the usage of this class.
139 +     * It never returns, but instead exits to the system
140 +     * with a value 1, to indicate the system did not start
141 +     * properly.
142 +     */
143 +    public static void usage() {
144 +        System.out.println("USAGE: java Core.java <option>");
145 +        System.out.println("WHERE <option>:");
146 +        System.out.println("      -l <filename> - the location of initial system properties");
147 +        System.out.println("      -h            - this help screen");
148 +        System.exit(1);
149      }
150  
151   //---CONSTRUCTORS---
# Line 102 | Line 160 | class Core {
160  
161   //---STATIC ATTRIBUTES---
162  
163 < }
163 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines