ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/filter/FilterMain.java
Revision: 1.1
Committed: Tue Nov 21 21:06:07 2000 UTC (23 years, 6 months ago) by tdb
Branch: MAIN
Log Message:
Renamed from Filter.java. Main method for the Filter.

File Contents

# Content
1 //---PACKAGE DECLARATION---
2
3 //---IMPORTS---
4 import uk.ac.ukc.iscream.core.*;
5 import uk.ac.ukc.iscream.filter.*;
6 import org.omg.CORBA.*;
7 import org.omg.CosNaming.*;
8 import org.omg.PortableServer.*;
9
10 /**
11 * A Filter Startup Class
12 *
13 * @author $Author: tdb1 $
14 * @version $Id: Filter.java,v 1.1 2000/11/20 22:03:41 tdb1 Exp $
15 */
16 class FilterMain {
17
18 //---FINAL ATTRIBUTES---
19
20 /**
21 * The current CVS revision of this class
22 */
23 public static final String REVISION = "$Revision: 1.1 $";
24
25 //---STATIC METHODS---
26
27 public static void main(String[] args) {
28 System.setProperty("org.omg.CORBA.ORBClass","jacorb.orb.ORB");
29 System.setProperty("org.omg.CORBA.ORBSingletonClass","jacorb.orb.ORBSingleton");
30
31 // get our name from the command line
32 String ourName = "";
33 if (args.length == 1) {
34 ourName = args[0];
35 }
36 else {
37 usage();
38 }
39
40 // can't have a real toString() :)
41 String toString = "Filter{" + ourName + "}(" + REVISION.substring(11, REVISION.length() - 2) + ")";
42
43 try {
44 ORB orb = ORB.init(args, null);
45
46 // something to hold objects
47 org.omg.CORBA.Object objRef = null;
48
49 // get the Root POA
50 objRef = orb.resolve_initial_references("RootPOA");
51 POA poa = POAHelper.narrow(objRef);
52
53 // get a hook to the name service
54 objRef = orb.resolve_initial_references("NameService");
55 NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
56
57 // get a ref to the ConfigurationManager, Logger & the FilterManager
58
59 objRef = ncRef.resolve(ncRef.to_name("iscream.ConfigurationManager"));
60 ConfigurationManager configManager = ConfigurationManagerHelper.narrow(objRef);
61
62 objRef = ncRef.resolve(ncRef.to_name("iscream.Logger"));
63 Logger logger = LoggerHelper.narrow(objRef);
64
65 //objRef = ncRef.resolve(ncRef.to_name("iscream.FilterManager"));
66 //FilterManager filterManager = FilterManagerHelper.narrow(objRef);
67
68 logger.write(toString, Logger.SYSINIT, "coming up");
69
70
71 // **** THIS SECTION WILL NEED CHANGING TO GET RELEVANT CONFIG
72 // **** Please ignore this block of code, it's just "copy/paste" :)
73
74 // get the config
75 Configuration myConfig = configManager.getConfiguration(ourName);
76
77 // read some config here
78
79 logger.write(toString, Logger.SYSINIT, "configured");
80
81 // **** END COMMENT
82
83 // SETUP our Servant
84
85 // create the FilterServant
86 FilterServant filterServant = new FilterServant(logger, ourName);
87
88 // and advertise it to the naming context
89 objRef = poa.servant_to_reference(filterServant);
90 ncRef.bind(ncRef.to_name("iscream.Filter."+ourName), objRef);
91
92 // END SETUP
93
94 /**************************************************************
95 */logger.write(toString, Logger.SYSINIT, "starting Filter UDP listener");/*
96 Here would be an ideal place to start another thread to do
97 the listening part of the Filter. Ideally it should just be
98 created and then run(). It may be necessary to pass some of
99 the following parameters into the thread by the constructor.
100
101 Logger logger
102 - a reference to a Logger object
103 FilterManager filterManager
104 - a reference to the system filter manager
105 ConfigurationManager configManager
106 - a reference to the system configuration manager
107 Configuration myConfig
108 - a reference to the configuration object for this
109 filter instance
110 String ourName
111 - our "identifier" name
112
113 **************************************************************/
114
115 // **** INITIAL FILTER MANAGER COMMUNICATIONS HERE
116
117 // get a root (CHANGE to use FilterManager)
118 objRef = ncRef.resolve(ncRef.to_name("iscream.Filter.root1"));
119 Filter root = FilterHelper.narrow(objRef);
120
121 // register ourselves
122
123 // **** END COMMENT
124
125 // TEST
126 root.receiveXML("test via Root1");
127
128 // start the POA off
129 poa.the_POAManager().activate();
130
131 logger.write(toString, Logger.SYSINIT, "started");
132
133 // now we are running, we just need to serve
134 // so we ask the orb to block for us until it has finished
135 orb.run();
136
137 } catch (Exception e) {
138 System.err.println("FILTER ERROR: " + e);
139 e.printStackTrace(System.out);
140 }
141 }
142
143 /**
144 * A simple method to print the usage of this class.
145 * It never returns, but instead exits to the system
146 * with a value 1, to indicate the system did not start
147 * properly.
148 */
149 public static void usage() {
150 System.out.println("USAGE: java Filter <name>");
151 System.out.println("WHERE <name>:");
152 System.out.println(" The unique identifier for the Filter in the system.");
153 System.exit(1);
154 }
155
156 //---CONSTRUCTORS---
157
158 //---PUBLIC METHODS---
159
160 //---PRIVATE METHODS---
161
162 //---ACCESSOR/MUTATOR METHODS---
163
164 //---ATTRIBUTES---
165
166 //---STATIC ATTRIBUTES---
167
168 }