1 |
//---PACKAGE DECLARATION--- |
2 |
package uk.ac.ukc.iscream.filtermanager; |
3 |
|
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 |
|
10 |
/** |
11 |
* A FilterManager |
12 |
* |
13 |
* @author $Author: tdb1 $ |
14 |
* @version $Id: FilterManager.java,v 1.8 2000/11/23 01:44:59 tdb1 Exp $ |
15 |
*/ |
16 |
class FilterManager { |
17 |
|
18 |
//---FINAL ATTRIBUTES--- |
19 |
|
20 |
/** |
21 |
* The current CVS revision of this class |
22 |
*/ |
23 |
public static final String REVISION = "$Revision: 1.8 $"; |
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 |
// can't have a real toString() :) |
32 |
String toString = "FilterManager(" + REVISION.substring(11, REVISION.length() - 2) + ")"; |
33 |
|
34 |
try { |
35 |
ORB orb = ORB.init(args, null); |
36 |
|
37 |
// something to hold objects |
38 |
org.omg.CORBA.Object objRef = null; |
39 |
|
40 |
// get a hook to the name service |
41 |
objRef = orb.resolve_initial_references("NameService"); |
42 |
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); |
43 |
|
44 |
// get a ref to the Configurator & the Logger |
45 |
objRef = ncRef.resolve(ncRef.to_name("iscream.ConfigurationManager")); |
46 |
ConfigurationManager configManager = ConfigurationManagerHelper.narrow(objRef); |
47 |
objRef = ncRef.resolve(ncRef.to_name("iscream.Logger")); |
48 |
Logger logger = LoggerHelper.narrow(objRef); |
49 |
|
50 |
logger.write(toString, Logger.SYSINIT, "coming up"); |
51 |
|
52 |
// create the servant |
53 |
//FilterManagerServant servant = new FilterManagerServant(logger); |
54 |
|
55 |
// register the servant with the name service |
56 |
//objRef = poa.servant_to_reference(servant); |
57 |
//ncRef.bind(ncRef.to_name("iscream.FilterManager"), objRef); |
58 |
|
59 |
// start the POA off |
60 |
//poa.the_POAManager().activate(); |
61 |
|
62 |
// get the config |
63 |
Configuration myConfig = configManager.getConfiguration("FilterManager"); |
64 |
|
65 |
// some place holders for the configuration |
66 |
int port = 0; |
67 |
|
68 |
// did we? |
69 |
if (myConfig == null) { |
70 |
System.out.println("Failed: is it there?, can you read it?"); |
71 |
System.exit(1); |
72 |
} else { |
73 |
|
74 |
// get the property |
75 |
try { |
76 |
port = new Integer(myConfig.getProperty("FilterManager.listenPort")).intValue(); |
77 |
} catch (org.omg.CORBA.MARSHAL e) { |
78 |
System.out.println("Caught org.omg.CORBA.MARSHAL, must be a null we got back"); |
79 |
System.exit(1); |
80 |
} |
81 |
} |
82 |
logger.write(toString, Logger.SYSMSG, "configured"); |
83 |
logger.write(toString, Logger.SYSINIT, "starting listener"); |
84 |
|
85 |
HostListener hostListener = new HostListener(logger, configManager, port, ncRef); |
86 |
hostListener.start(); |
87 |
|
88 |
logger.write(toString, Logger.SYSINIT, "started"); |
89 |
|
90 |
} catch (Exception e) { |
91 |
System.err.println("FILTER MANAGER ERROR: " + e); |
92 |
e.printStackTrace(System.out); |
93 |
} |
94 |
} |
95 |
|
96 |
//---CONSTRUCTORS--- |
97 |
|
98 |
//---PUBLIC METHODS--- |
99 |
|
100 |
//---PRIVATE METHODS--- |
101 |
|
102 |
//---ACCESSOR/MUTATOR METHODS--- |
103 |
|
104 |
//---ATTRIBUTES--- |
105 |
|
106 |
//---STATIC ATTRIBUTES--- |
107 |
|
108 |
} |