ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/rootfilter/RootFilter.java
Revision: 1.3
Committed: Wed Nov 29 19:33:35 2000 UTC (23 years, 5 months ago) by tdb
Branch: MAIN
Changes since 1.2: +3 -2 lines
Log Message:
Made changes to fit in with the new package structure. Also made sure all files
conform to the template class.

File Contents

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