1 |
tdb |
1.13 |
//---PACKAGE DECLARATION--- |
2 |
ajm |
1.16 |
package uk.ac.ukc.iscream.core; |
3 |
tdb |
1.13 |
|
4 |
|
|
//---IMPORTS--- |
5 |
ajm |
1.17 |
import uk.ac.ukc.iscream.util.ReferenceManager; |
6 |
|
|
|
7 |
|
|
import org.omg.CORBA.ORB; |
8 |
tdb |
1.13 |
import org.omg.CosNaming.*; |
9 |
|
|
import org.omg.PortableServer.*; |
10 |
ajm |
1.17 |
import uk.ac.ukc.iscream.core.*; |
11 |
tdb |
1.13 |
|
12 |
|
|
/** |
13 |
|
|
* The main class for the CORE of the I-Scream system. |
14 |
|
|
* The main method of this class initialises the ORB |
15 |
|
|
* and then starts and registers CORE I-Scream services |
16 |
|
|
* with the name service. At which point it essentially |
17 |
|
|
* finishs its role and the started services continue to |
18 |
|
|
* serve requests from the I-Scream system. |
19 |
|
|
* |
20 |
ajm |
1.17 |
* @author $Author: ajm4 $ |
21 |
|
|
* @version $Id: Core.java,v 1.16 2000/11/29 21:27:08 ajm4 Exp $ |
22 |
tdb |
1.13 |
*/ |
23 |
ajm |
1.17 |
public class Core implements uk.ac.ukc.iscream.util.Component { |
24 |
tdb |
1.13 |
|
25 |
|
|
//---FINAL ATTRIBUTES--- |
26 |
|
|
|
27 |
|
|
/** |
28 |
|
|
* The current CVS revision of this class |
29 |
|
|
*/ |
30 |
ajm |
1.17 |
public static final String REVISION = "$Revision: 1.16 $"; |
31 |
tdb |
1.13 |
|
32 |
|
|
/** |
33 |
|
|
* The toString() of this class |
34 |
|
|
* As it won't be instatiated, this is needed. |
35 |
|
|
*/ |
36 |
|
|
public static final String toString = "CORE(" + REVISION.substring(11, REVISION.length() - 2) + ")"; |
37 |
|
|
|
38 |
|
|
/** |
39 |
|
|
* The default location of the properties file for the system |
40 |
|
|
*/ |
41 |
|
|
public static final String DEFAULTPROPERTIES = "default.properties"; |
42 |
|
|
|
43 |
|
|
//---STATIC METHODS--- |
44 |
|
|
|
45 |
ajm |
1.17 |
//---CONSTRUCTORS--- |
46 |
|
|
|
47 |
|
|
//---PUBLIC METHODS--- |
48 |
|
|
|
49 |
tdb |
1.13 |
/** |
50 |
|
|
* The main method which starts the CORE |
51 |
|
|
* Currently the args are passed direct to the ORB, |
52 |
|
|
* so any ORB paramaters could go there. |
53 |
|
|
* |
54 |
|
|
* @param args the command line arguments |
55 |
|
|
*/ |
56 |
ajm |
1.17 |
public boolean start() { |
57 |
|
|
// start and bind each server in turn |
58 |
|
|
|
59 |
|
|
// work out which logger to use |
60 |
|
|
String whichLogger = System.getProperty("uk.ac.ukc.iscream.LoggerClass"); |
61 |
|
|
String loggerPackage = System.getProperty("uk.ac.ukc.iscream.LoggerPackage"); |
62 |
|
|
|
63 |
|
|
// construct the relevant LoggerImpl |
64 |
|
|
LoggerImpl loggerImplRef = null; |
65 |
tdb |
1.13 |
try { |
66 |
ajm |
1.17 |
loggerImplRef = (LoggerImpl) ClassLoader.getSystemClassLoader().loadClass(loggerPackage + "." + whichLogger).newInstance(); |
67 |
tdb |
1.13 |
} catch (Exception e) { |
68 |
ajm |
1.17 |
System.err.println(toString + ": ERROR Unable to start Logger - " + e.getMessage()); |
69 |
|
|
// so return false to indicate failure |
70 |
|
|
return false; |
71 |
tdb |
1.13 |
} |
72 |
ajm |
1.17 |
|
73 |
|
|
// setup and bind the LoggerServant |
74 |
|
|
LoggerServant loggerRef = new LoggerServant(loggerImplRef); |
75 |
|
|
_refman.bindToOrb(loggerRef, "iscream.Logger"); |
76 |
tdb |
1.13 |
|
77 |
ajm |
1.17 |
// get a reference to the servant as a Logger |
78 |
|
|
_logger = _refman.getLogger(); |
79 |
tdb |
1.13 |
|
80 |
ajm |
1.17 |
// create the Configurator |
81 |
|
|
ConfigurationManagerServant configManRef = new ConfigurationManagerServant(_refman.getRootPOA(), _refman.getLogger()); |
82 |
|
|
|
83 |
|
|
// and advertise it to the naming context |
84 |
|
|
_refman.bindToOrb(configManRef, "iscream.ConfigurationManager"); |
85 |
|
|
|
86 |
|
|
_logger.write(toString, Logger.SYSINIT, "started"); |
87 |
|
|
|
88 |
|
|
// we were ok starting... |
89 |
|
|
return true; |
90 |
tdb |
1.13 |
} |
91 |
|
|
|
92 |
|
|
//---PRIVATE METHODS--- |
93 |
|
|
|
94 |
|
|
//---ACCESSOR/MUTATOR METHODS--- |
95 |
|
|
|
96 |
|
|
//---ATTRIBUTES--- |
97 |
ajm |
1.17 |
|
98 |
|
|
Logger _logger; |
99 |
|
|
ReferenceManager _refman = ReferenceManager.getInstance(); |
100 |
tdb |
1.13 |
|
101 |
|
|
//---STATIC ATTRIBUTES--- |
102 |
|
|
|
103 |
|
|
} |