2 |
|
package uk.ac.ukc.iscream.componentmanager; |
3 |
|
|
4 |
|
//---IMPORTS--- |
5 |
< |
import uk.ac.ukc.iscream.util.Component; |
6 |
< |
import uk.ac.ukc.iscream.util.ReferenceManager; |
5 |
> |
import uk.ac.ukc.iscream.util.*; |
6 |
|
import java.util.*; |
7 |
|
import java.io.*; |
8 |
|
|
9 |
|
/** |
10 |
+ |
* The component manager is the starting point for all |
11 |
+ |
* server side components of the iscream system. |
12 |
+ |
* It loads its initial system configuration from the |
13 |
+ |
* default properties file, it then starts all the iscream |
14 |
+ |
* components as specified in the default.properties under |
15 |
+ |
* uk.ac.ukc.iscream.ComponentList |
16 |
|
* |
12 |
– |
* |
17 |
|
* @author $Author$ |
18 |
|
* @version $Id$ |
19 |
|
*/ |
29 |
|
/** |
30 |
|
* The toString() of this class |
31 |
|
* As it won't be instatiated, this is needed. |
32 |
+ |
* Not also that we pass a null as the class name (as we are static) |
33 |
|
*/ |
34 |
< |
public static final String toString = "ComponentManager(" + REVISION.substring(11, REVISION.length() - 2) + ")"; |
34 |
> |
public static final String toString = FormatName.getName("ComponentManager", null, REVISION); |
35 |
|
|
36 |
|
/** |
37 |
|
* The default location of the properties file for the system |
38 |
|
*/ |
39 |
< |
public static final String DEFAULTPROPERTIES = "default.properties"; |
39 |
> |
public static final String DEFAULTPROPERTIES = "./etc/default.properties"; |
40 |
|
|
41 |
|
//---STATIC METHODS--- |
42 |
|
|
43 |
|
/** |
44 |
< |
* The main method which starts the CORE |
45 |
< |
* Currently the args are passed direct to the ORB, |
41 |
< |
* so any ORB paramaters could go there. |
44 |
> |
* The main method which starts the components as |
45 |
> |
* listed in the default.properties file. |
46 |
|
* |
47 |
|
* @param args the command line arguments |
48 |
|
*/ |
49 |
|
public static void main(String[] args) { |
50 |
|
System.out.println("--- I-Scream System Component Manager ---"); |
51 |
< |
|
51 |
> |
System.out.println("--- Starting System ---"); |
52 |
> |
|
53 |
|
// get the command line args |
54 |
|
// this is a bit messy and should be looked at |
55 |
|
String defaultProperties = DEFAULTPROPERTIES; |
83 |
|
System.out.println(toString + ": coming up"); |
84 |
|
|
85 |
|
// start the ORB by initialising the ReferenceManager |
86 |
< |
ReferenceManager refman = ReferenceManager.init(null, null); |
86 |
> |
ReferenceManager refman = ReferenceManager.getInstance(); |
87 |
|
|
88 |
< |
// now we are running, we just need to serve |
89 |
< |
// so we ask the orb to block for us until it has finished |
88 |
> |
// now the ORB is running, we need to activate our RootPOA |
89 |
> |
// so that we can start serving requests once servants start up |
90 |
|
refman.activatePOA(); |
91 |
|
|
92 |
+ |
// get the list of components |
93 |
|
String componentList = System.getProperty("uk.ac.ukc.iscream.ComponentList"); |
94 |
|
StringTokenizer st = new StringTokenizer(componentList, ";"); |
95 |
|
|
99 |
|
String componentName = st.nextToken(); |
100 |
|
Component component = null; |
101 |
|
System.out.println(toString + ": starting component - " + componentName); |
102 |
< |
if (componentName.equalsIgnoreCase("CoRe")) { |
102 |
> |
|
103 |
> |
// ### This is where the list of supported components is checked! ### |
104 |
> |
if (componentName.equalsIgnoreCase("core")) { |
105 |
|
component = new uk.ac.ukc.iscream.core.Core(); |
106 |
+ |
} else if (componentName.equalsIgnoreCase("filtermanager")) { |
107 |
+ |
component = new uk.ac.ukc.iscream.filtermanager.FilterManager(); |
108 |
+ |
} else if (componentName.equalsIgnoreCase("rootfilter")) { |
109 |
+ |
component = new uk.ac.ukc.iscream.rootfilter.RootFilter(); |
110 |
+ |
} else if (componentName.equalsIgnoreCase("dbinterface")) { |
111 |
+ |
component = new uk.ac.ukc.iscream.dbinterface.DBInterface(); |
112 |
|
} |
113 |
+ |
// ### Add new component constructors in the above section! ### |
114 |
+ |
|
115 |
|
if (component != null) { |
116 |
< |
boolean result = component.start(); |
117 |
< |
if (result == false) { |
116 |
> |
try { |
117 |
> |
component.start(); |
118 |
> |
} catch (ComponentStartException e) { |
119 |
|
System.err.println(toString + ": ERROR starting component - " + componentName); |
120 |
+ |
System.err.println(toString + ": component reports - " + e.getMessage()); |
121 |
|
System.exit(1); |
122 |
|
} |
123 |
|
} else { |
124 |
|
System.err.println(toString + ": WARNING unsupported component not started"); |
125 |
|
} |
126 |
|
} |
127 |
< |
System.out.println(toString + ": finished - blocking on ORB"); |
128 |
< |
//refman.activatePOA(); |
127 |
> |
System.out.println(toString + ": running"); |
128 |
> |
|
129 |
> |
// block on the ORB...in time, management functionality can be placed here. |
130 |
|
refman.getORB().run(); |
131 |
|
} |
132 |
< |
|
133 |
< |
/** |
132 |
> |
|
133 |
> |
/** |
134 |
|
* A simple method to print the usage of this class. |
135 |
|
* It never returns, but instead exits to the system |
136 |
|
* with a value 1, to indicate the system did not start |
140 |
|
System.out.println("USAGE: java uk.ac.ukc.iscream.componentmanager.ComponentManager <option>"); |
141 |
|
System.out.println("WHERE <option>:"); |
142 |
|
System.out.println(" -l <filename> - the location of initial system properties"); |
143 |
+ |
System.out.println(" the default is ./etc/default.properties"); |
144 |
|
System.out.println(" -f <name> - the name of the filter (if there is one configured"); |
145 |
|
System.out.println(" -h - this help screen"); |
146 |
|
System.exit(1); |