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.18 |
import uk.ac.ukc.iscream.util.*; |
6 |
tdb |
1.21 |
import uk.ac.ukc.iscream.componentmanager.*; |
7 |
tdb |
1.13 |
|
8 |
|
|
/** |
9 |
|
|
* The main class for the CORE of the I-Scream system. |
10 |
ajm |
1.18 |
* This class is the component for CORE I-Scream services |
11 |
|
|
* namely the Logger and the ConfigurationManager. |
12 |
|
|
* It registers and starts them, at which point it essentially |
13 |
tdb |
1.13 |
* finishs its role and the started services continue to |
14 |
|
|
* serve requests from the I-Scream system. |
15 |
|
|
* |
16 |
tdb |
1.22 |
* @author $Author: tdb1 $ |
17 |
tdb |
1.23 |
* @version $Id: Core.java,v 1.22 2001/01/18 23:11:57 tdb1 Exp $ |
18 |
tdb |
1.13 |
*/ |
19 |
tdb |
1.22 |
public class Core implements Component { |
20 |
tdb |
1.13 |
|
21 |
|
|
//---FINAL ATTRIBUTES--- |
22 |
|
|
|
23 |
|
|
/** |
24 |
|
|
* The current CVS revision of this class |
25 |
|
|
*/ |
26 |
tdb |
1.23 |
public static final String REVISION = "$Revision: 1.22 $"; |
27 |
tdb |
1.13 |
|
28 |
|
|
/** |
29 |
ajm |
1.20 |
* The friendly name for this component, used by |
30 |
ajm |
1.18 |
* all related classes. |
31 |
tdb |
1.13 |
*/ |
32 |
ajm |
1.19 |
public static final String NAME = "Core"; |
33 |
tdb |
1.13 |
|
34 |
|
|
//---STATIC METHODS--- |
35 |
|
|
|
36 |
ajm |
1.17 |
//---CONSTRUCTORS--- |
37 |
|
|
|
38 |
|
|
//---PUBLIC METHODS--- |
39 |
|
|
|
40 |
tdb |
1.13 |
/** |
41 |
ajm |
1.18 |
* This method starts the CORE |
42 |
tdb |
1.13 |
* Currently the args are passed direct to the ORB, |
43 |
|
|
* so any ORB paramaters could go there. |
44 |
|
|
* |
45 |
|
|
*/ |
46 |
ajm |
1.18 |
public void start() throws ComponentStartException { |
47 |
ajm |
1.17 |
// start and bind each server in turn |
48 |
|
|
|
49 |
|
|
// work out which logger to use |
50 |
|
|
String whichLogger = System.getProperty("uk.ac.ukc.iscream.LoggerClass"); |
51 |
|
|
String loggerPackage = System.getProperty("uk.ac.ukc.iscream.LoggerPackage"); |
52 |
|
|
|
53 |
|
|
// construct the relevant LoggerImpl |
54 |
|
|
LoggerImpl loggerImplRef = null; |
55 |
tdb |
1.13 |
try { |
56 |
ajm |
1.17 |
loggerImplRef = (LoggerImpl) ClassLoader.getSystemClassLoader().loadClass(loggerPackage + "." + whichLogger).newInstance(); |
57 |
tdb |
1.13 |
} catch (Exception e) { |
58 |
ajm |
1.18 |
// if anything goes wrong we throw a failed start exception |
59 |
|
|
throw new ComponentStartException("unable to load logging class"); |
60 |
tdb |
1.13 |
} |
61 |
ajm |
1.19 |
|
62 |
ajm |
1.17 |
// setup and bind the LoggerServant |
63 |
|
|
LoggerServant loggerRef = new LoggerServant(loggerImplRef); |
64 |
|
|
_refman.bindToOrb(loggerRef, "iscream.Logger"); |
65 |
tdb |
1.13 |
|
66 |
ajm |
1.17 |
// get a reference to the servant as a Logger |
67 |
|
|
_logger = _refman.getLogger(); |
68 |
tdb |
1.13 |
|
69 |
ajm |
1.17 |
// create the Configurator |
70 |
ajm |
1.18 |
ConfigurationManagerServant configManRef = new ConfigurationManagerServant(); |
71 |
ajm |
1.17 |
|
72 |
|
|
// and advertise it to the naming context |
73 |
|
|
_refman.bindToOrb(configManRef, "iscream.ConfigurationManager"); |
74 |
|
|
|
75 |
ajm |
1.18 |
_logger.write(toString(), Logger.SYSINIT, "started"); |
76 |
tdb |
1.23 |
} |
77 |
|
|
|
78 |
|
|
/** |
79 |
|
|
* Does a dependency check. Used mainly at startup to |
80 |
|
|
* see if the required dependencies (components) are up |
81 |
|
|
* and running. |
82 |
|
|
* |
83 |
|
|
* @return a boolean value, true if the depdencies are satisfied |
84 |
|
|
*/ |
85 |
|
|
public boolean depCheck() { |
86 |
|
|
// the core has no depedencies |
87 |
|
|
return true; |
88 |
ajm |
1.18 |
} |
89 |
|
|
|
90 |
|
|
/** |
91 |
|
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
92 |
|
|
* method to provide clean logging (every class should have this). |
93 |
|
|
* |
94 |
|
|
* This uses the uk.ac.ukc.iscream.util.NameFormat class |
95 |
|
|
* to format the toString() |
96 |
|
|
* |
97 |
|
|
* @return the name of this class and its CVS revision |
98 |
|
|
*/ |
99 |
|
|
public String toString() { |
100 |
|
|
return FormatName.getName( |
101 |
|
|
_name, |
102 |
ajm |
1.20 |
getClass().getName(), |
103 |
ajm |
1.18 |
REVISION); |
104 |
tdb |
1.13 |
} |
105 |
|
|
|
106 |
|
|
//---PRIVATE METHODS--- |
107 |
|
|
|
108 |
|
|
//---ACCESSOR/MUTATOR METHODS--- |
109 |
|
|
|
110 |
|
|
//---ATTRIBUTES--- |
111 |
ajm |
1.18 |
|
112 |
|
|
/** |
113 |
|
|
* This is the friendly identifier of the |
114 |
|
|
* component this class is running in. |
115 |
|
|
* eg, a Filter may be called "filter1", |
116 |
|
|
* If this class does not have an owning |
117 |
|
|
* component, a name from the configuration |
118 |
|
|
* can be placed here. This name could also |
119 |
|
|
* be changed to null for utility classes. |
120 |
|
|
*/ |
121 |
|
|
private String _name = Core.NAME; |
122 |
|
|
|
123 |
|
|
/** |
124 |
|
|
* This holds a reference to the |
125 |
|
|
* system logger that is being used. |
126 |
|
|
*/ |
127 |
|
|
private Logger _logger; |
128 |
|
|
|
129 |
|
|
/** |
130 |
|
|
* A reference to the reference manager in use |
131 |
|
|
*/ |
132 |
|
|
private ReferenceManager _refman = ReferenceManager.getInstance(); |
133 |
tdb |
1.13 |
|
134 |
|
|
//---STATIC ATTRIBUTES--- |
135 |
|
|
|
136 |
|
|
} |