ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/componentmanager/ComponentManager.java
Revision: 1.1
Committed: Mon Dec 11 16:41:33 2000 UTC (23 years, 5 months ago) by ajm
Branch: MAIN
Log Message:
initial checkin

This componentmanager will be the way of starting the system
Currently only the core component is supported

File Contents

# Content
1 //---PACKAGE DECLARATION---
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;
7 import java.util.*;
8 import java.io.*;
9
10 /**
11 *
12 *
13 * @author $Author: ajm4 $
14 * @version $Id: Core.java,v 1.16 2000/11/29 21:27:08 ajm4 Exp $
15 */
16 public class ComponentManager {
17
18 //---FINAL ATTRIBUTES---
19
20 /**
21 * The current CVS revision of this class
22 */
23 public static final String REVISION = "$Revision: 1.16 $";
24
25 /**
26 * The toString() of this class
27 * As it won't be instatiated, this is needed.
28 */
29 public static final String toString = "ComponentManager(" + REVISION.substring(11, REVISION.length() - 2) + ")";
30
31 /**
32 * The default location of the properties file for the system
33 */
34 public static final String DEFAULTPROPERTIES = "default.properties";
35
36 //---STATIC METHODS---
37
38 /**
39 * The main method which starts the CORE
40 * Currently the args are passed direct to the ORB,
41 * so any ORB paramaters could go there.
42 *
43 * @param args the command line arguments
44 */
45 public static void main(String[] args) {
46 System.out.println("--- I-Scream System Component Manager ---");
47
48 // get the command line args
49 // this is a bit messy and should be looked at
50 String defaultProperties = DEFAULTPROPERTIES;
51 String filterName = null;
52 if (args.length > 0) {
53 if (args[0].equals("-l")) {
54 defaultProperties = args[1];
55 } else if (args[0].equals("-f")) {
56 filterName = args[1];
57 } else if (args[2].equals("-l")) {
58 filterName = args[3];
59 } else if (args[2].equals("-f")) {
60 filterName = args[3];
61 } else {
62 usage();
63 }
64 }
65
66 // load the default properties file into the system properties
67 System.out.println(toString + ": initialising - using " + defaultProperties);
68 try {
69 Properties initProperties = new Properties(System.getProperties());
70 initProperties.load(new FileInputStream(new File(defaultProperties)));
71 System.setProperties(initProperties);
72 } catch (Exception e) {
73 System.err.println(toString + ": ERROR " + e.getMessage());
74 usage();
75 }
76
77 // continue to bring the system up
78 System.out.println(toString + ": coming up");
79
80 // start the ORB by initialising the ReferenceManager
81 ReferenceManager refman = ReferenceManager.init(null, null);
82
83 // now we are running, we just need to serve
84 // so we ask the orb to block for us until it has finished
85 refman.activatePOA();
86
87 String componentList = System.getProperty("uk.ac.ukc.iscream.ComponentList");
88 StringTokenizer st = new StringTokenizer(componentList, ";");
89
90 // this could be done using reflection
91 // but..well..we don't ;-p
92 while (st.hasMoreTokens()){
93 String componentName = st.nextToken();
94 Component component = null;
95 System.out.println(toString + ": starting component - " + componentName);
96 if (componentName.equalsIgnoreCase("CoRe")) {
97 component = new uk.ac.ukc.iscream.core.Core();
98 }
99 if (component != null) {
100 boolean result = component.start();
101 if (result == false) {
102 System.err.println(toString + ": ERROR starting component - " + componentName);
103 System.exit(1);
104 }
105 } else {
106 System.err.println(toString + ": WARNING unsupported component not started");
107 }
108 }
109 System.out.println(toString + ": finished - blocking on ORB");
110 //refman.activatePOA();
111 refman.getORB().run();
112 }
113
114 /**
115 * A simple method to print the usage of this class.
116 * It never returns, but instead exits to the system
117 * with a value 1, to indicate the system did not start
118 * properly.
119 */
120 public static void usage() {
121 System.out.println("USAGE: java uk.ac.ukc.iscream.componentmanager.ComponentManager <option>");
122 System.out.println("WHERE <option>:");
123 System.out.println(" -l <filename> - the location of initial system properties");
124 System.out.println(" -f <name> - the name of the filter (if there is one configured");
125 System.out.println(" -h - this help screen");
126 System.exit(1);
127 }
128
129 //---CONSTRUCTORS---
130
131 //---PUBLIC METHODS---
132
133 //---PRIVATE METHODS---
134
135 //---ACCESSOR/MUTATOR METHODS---
136
137 //---ATTRIBUTES---
138
139 //---STATIC ATTRIBUTES---
140
141 }