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
Revision: 1.5
Committed: Mon Nov 13 18:21:15 2000 UTC (23 years, 6 months ago) by tdb
Branch: MAIN
Changes since 1.4: +10 -6 lines
Log Message:
Modified the toString of all the classes to bring in line with the standard

Modified CORE to startup nicer (output wise)

File Contents

# User Rev Content
1 ajm 1.1 //---PACKAGE DECLARATION---
2    
3     //---IMPORTS---
4 tdb 1.4 import uk.ac.ukc.iscream.core.*;
5 ajm 1.1 import org.omg.CORBA.*;
6     import org.omg.CosNaming.*;
7     import org.omg.PortableServer.*;
8    
9     /**
10     * The main class for the CORE of the I-Scream system.
11     * The main method of this class initialises the ORB
12     * and then starts and registers CORE I-Scream services
13     * with the name service. At which point it essentially
14     * finishs its role and the started services continue to
15     * serve requests from the I-Scream system.
16     *
17 tdb 1.3 * @author $Author: tdb1 $
18 tdb 1.5 * @version $Id: Core.java,v 1.4 2000/11/13 16:36:03 tdb1 Exp $
19 ajm 1.1 */
20     class Core {
21    
22     //---FINAL ATTRIBUTES---
23    
24     /**
25     * The current CVS revision of this class
26     */
27 tdb 1.5 public static final String REVISION = "$Revision: 1.4 $";
28 ajm 1.1
29     //---STATIC METHODS---
30    
31     /**
32     * The main method which starts the CORE
33     * Currently the args are passed direct to the ORB,
34     * so any ORB paramaters could go there.
35     *
36     * @param args the command line arguments
37     */
38     public static void main(String[] args) {
39 tdb 1.5 System.out.println("--- I-Scream ---");
40    
41     // can't have a real toString() :)
42     String toString = "CORE(" + REVISION.substring(11, REVISION.length() - 2) + ")";
43    
44     System.out.println(toString + ": coming up");
45    
46 ajm 1.1 try {
47     // start the ORB
48     ORB orb = ORB.init(args, null);
49    
50     // get the Root POA
51     org.omg.CORBA.Object objRef = orb.resolve_initial_references("RootPOA");
52     POA poa = POAHelper.narrow(objRef);
53    
54     // get a hook to the name service
55     objRef = orb.resolve_initial_references("NameService");
56     NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
57    
58 tdb 1.3 // start and bind each server in turn
59    
60     // create the logger (either Screen or File)
61     ScreenLoggerServant loggerRef = new ScreenLoggerServant();
62     //FileLoggerServant loggerRef = new FileLoggerServant("core.log");
63     // and advertise it to the naming context
64     objRef = poa.servant_to_reference(loggerRef);
65     ncRef.bind(ncRef.to_name("iscream.Logger"), objRef);
66 ajm 1.1
67 tdb 1.3 // get a ref to the logger servant as a Logger reference
68     Logger logRef = LoggerHelper.narrow(objRef);
69 ajm 1.1
70 tdb 1.3 // create the Configurator
71     ConfiguratorServant configuratorRef = new ConfiguratorServant(poa, logRef);
72     // and advertise it to the naming context
73 ajm 1.1 objRef = poa.servant_to_reference(configuratorRef);
74     ncRef.bind(ncRef.to_name("iscream.Configurator"), objRef);
75    
76     // start the POA off
77 tdb 1.2 poa.the_POAManager().activate();
78 tdb 1.5
79 tdb 1.3 logRef.write(toString, "started");
80 ajm 1.1
81     // now we are running, we just need to serve
82     // so we ask the orb to block for us until it has finished
83     orb.run();
84    
85     // if there was a problem then we'll get to here
86     } catch (Exception e) {
87    
88     // there is already another CORE of the same name registered
89     if ( e instanceof org.omg.CosNaming.NamingContextPackage.AlreadyBound) {
90     System.err.println("ERROR: Another I-Scream CORE is already registered under the same name.");
91    
92     // otherwise we don't know what happened
93     // so print the error and do a stack trace
94     } else {
95     System.err.println("CORE ERROR: " + e);
96     e.printStackTrace(System.out);
97     }
98     }
99     }
100    
101     //---CONSTRUCTORS---
102    
103     //---PUBLIC METHODS---
104    
105     //---PRIVATE METHODS---
106    
107     //---ACCESSOR/MUTATOR METHODS---
108    
109     //---ATTRIBUTES---
110    
111     //---STATIC ATTRIBUTES---
112    
113 tdb 1.2 }