59 |
|
public static final String DEFAULTPROPERTIES = "./etc/default.properties"; |
60 |
|
|
61 |
|
/** |
62 |
< |
* The default time to wait before retrying |
62 |
> |
* The default time to wait before retrying |
63 |
|
* component. |
64 |
|
*/ |
65 |
|
public static final int DEFAULT_COMPONENT_START_TIMEOUT = 5; |
78 |
|
System.out.println("--- (c) 2001 The i-scream Project ---"); |
79 |
|
System.out.println("--- (http://www.i-scream.org.uk) ---"); |
80 |
|
System.out.println("-----------------------------------------"); |
81 |
< |
System.out.println("--- Starting System ---"); |
81 |
> |
System.out.println("--- Starting System ---"); |
82 |
|
|
83 |
|
// get the command line args |
84 |
|
String defaultProperties = DEFAULTPROPERTIES; |
85 |
|
String filterName = null; |
86 |
|
String filterManagerName = null; |
87 |
+ |
String clientInterfaceName = null; |
88 |
|
for(int i=0; i < args.length; i++) { |
89 |
|
if(args[i].equals("-h")) { |
90 |
|
usage(); |
105 |
|
usage(); |
106 |
|
} |
107 |
|
} |
108 |
+ |
else if(args[i].equals("-ci")) { |
109 |
+ |
if(++i < args.length) { |
110 |
+ |
clientInterfaceName = args[i]; |
111 |
+ |
} |
112 |
+ |
else { |
113 |
+ |
usage(); |
114 |
+ |
} |
115 |
+ |
} |
116 |
|
else if(args[i].equals("-l")) { |
117 |
|
if(++i < args.length) { |
118 |
|
defaultProperties = args[i]; |
167 |
|
component = new uk.org.iscream.cms.server.filtermanager.FilterManager(filterManagerName); |
168 |
|
} else if (componentName.equalsIgnoreCase("rootfilter")) { |
169 |
|
component = new uk.org.iscream.cms.server.rootfilter.RootFilter(); |
161 |
– |
} else if (componentName.equalsIgnoreCase("dbinterface")) { |
162 |
– |
component = new uk.org.iscream.cms.server.dbinterface.DBInterface(); |
170 |
|
} else if (componentName.equalsIgnoreCase("clientinterface")) { |
171 |
< |
component = new uk.org.iscream.cms.server.clientinterface.ClientInterfaceMain(); |
171 |
> |
component = new uk.org.iscream.cms.server.clientinterface.ClientInterfaceMain(clientInterfaceName); |
172 |
|
// note the passing of the Filter's name in its constructor |
173 |
|
} else if (componentName.equalsIgnoreCase("filter")) { |
174 |
|
component = new uk.org.iscream.cms.server.filter.FilterMain(filterName); |
179 |
|
|
180 |
|
// build the list of components to start |
181 |
|
if (component != null) { |
182 |
< |
_componentsToStart.add(component); |
182 |
> |
_componentsToStart.add(component); |
183 |
|
} else { |
184 |
|
System.err.println(toString + ": WARNING unsupported component not started: "+componentName); |
185 |
|
} |
203 |
|
// startup the system components |
204 |
|
startUp(); |
205 |
|
|
206 |
< |
// block on the ORB...in time, management functionality can be placed here. |
207 |
< |
// if we detect a CORBA communication error, we'll restart all the components. |
208 |
< |
// !! this doesn't appear to work !! |
209 |
< |
while(true) { |
210 |
< |
try { |
206 |
> |
// block on the ORB...in time, management functionality can be placed here. |
207 |
> |
// if we detect a CORBA communication error, we'll restart all the components. |
208 |
> |
// !! this doesn't appear to work !! |
209 |
> |
while(true) { |
210 |
> |
try { |
211 |
|
refman.getORB().run(); |
212 |
|
} catch (org.omg.CORBA.COMM_FAILURE e) { |
213 |
|
System.out.println(toString + ": WARNING CORBA communications failure - " + e.getMessage()); |
228 |
|
* is called again. |
229 |
|
*/ |
230 |
|
private static void startUp() { |
231 |
< |
// now we try and start the beast up |
231 |
> |
// now we try and start the beast up |
232 |
|
boolean tryAgain = true; |
233 |
|
Component component = null; |
234 |
|
|
239 |
|
LinkedList failedComponents = new LinkedList(); |
240 |
|
// go through all the components |
241 |
|
while(i.hasNext()) { |
242 |
< |
// get a refence to the component |
243 |
< |
component = (Component) i.next(); |
244 |
< |
System.out.println(toString + ": dependency checking component - " + component.toString()); |
245 |
< |
|
246 |
< |
// check it's dependencies |
247 |
< |
boolean depOK = component.depCheck(); |
248 |
< |
if(depOK) { |
249 |
< |
System.out.println(toString + ": starting component - " + component.toString()); |
250 |
< |
// it should be ok to start the component |
251 |
< |
try { |
252 |
< |
// start the component |
242 |
> |
// get a refence to the component |
243 |
> |
component = (Component) i.next(); |
244 |
> |
System.out.println(toString + ": dependency checking component - " + component.toString()); |
245 |
> |
|
246 |
> |
// check it's dependencies |
247 |
> |
boolean depOK = component.depCheck(); |
248 |
> |
if(depOK) { |
249 |
> |
System.out.println(toString + ": starting component - " + component.toString()); |
250 |
> |
// it should be ok to start the component |
251 |
> |
try { |
252 |
> |
// start the component |
253 |
|
component.start(); |
254 |
|
} catch (ComponentStartException e) { |
255 |
|
// if we get this then there was a problem |
279 |
|
_componentsToStart = failedComponents; |
280 |
|
|
281 |
|
// sleep for a given timeout |
282 |
< |
try { |
282 |
> |
try { |
283 |
|
Thread.sleep(_startTimeout * 1000); |
284 |
|
} catch (InterruptedException e) { |
285 |
|
// we're not bothered |
290 |
|
tryAgain = false; |
291 |
|
} |
292 |
|
} |
293 |
< |
|
294 |
< |
System.out.println(toString + ": running"); |
295 |
< |
} |
293 |
> |
|
294 |
> |
System.out.println(toString + ": running"); |
295 |
> |
} |
296 |
|
|
297 |
|
/** |
298 |
|
* A simple method to print the usage of this class. |
308 |
|
System.out.println(" the default is ./etc/default.properties"); |
309 |
|
System.out.println(" -f <name> - the name of the filter (if there is one configured"); |
310 |
|
System.out.println(" -fm <name> - the name of the filter manager (if there is one configured"); |
311 |
+ |
System.out.println(" -ci <name> - the name of the client interface (if there is one configured"); |
312 |
|
System.out.println(" -h - this help screen"); |
313 |
|
System.exit(1); |
314 |
|
} |