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.13
Committed: Thu Nov 30 02:18:51 2000 UTC (23 years, 5 months ago) by ajm
Branch: MAIN
Changes since 1.12: +57 -128 lines
Log Message:
Tidied up all the code
Used ReferenceManager to provide all ORB services

File Contents

# Content
1 //---PACKAGE DECLARATION---
2 package uk.ac.ukc.iscream.filter;
3
4 //---IMPORTS---
5 import uk.ac.ukc.iscream.refman.*;
6 import uk.ac.ukc.iscream.core.*;
7 import uk.ac.ukc.iscream.filter.*;
8 import org.omg.CORBA.*;
9 import org.omg.CosNaming.*;
10 import org.omg.PortableServer.*;
11
12 /**
13 * A Filter Startup Class
14 *
15 * @author $Author: ajm4 $
16 * @version $Id: FilterMain.java,v 1.12 2000/11/29 21:27:39 ajm4 Exp $
17 */
18 class FilterMain {
19
20 //---FINAL ATTRIBUTES---
21
22 /**
23 * The current CVS revision of this class
24 */
25 public static final String REVISION = "$Revision: 1.12 $";
26
27 //---STATIC METHODS---
28
29 public static void main(String[] args) {
30 // ***************************************
31 // VERY TEMPORARY - will find a better way
32 System.setProperty("org.omg.CORBA.ORBClass","jacorb.orb.ORB");
33 System.setProperty("org.omg.CORBA.ORBSingletonClass","jacorb.orb.ORBSingleton");
34 // ***************************************
35
36 // get our name from the command line
37 String ourName = "";
38 if (args.length == 1) {
39 ourName = args[0];
40 }
41 else {
42 usage();
43 }
44
45 // can't have a real toString() :)
46 String toString = "Filter{" + ourName + "}(" + REVISION.substring(11, REVISION.length() - 2) + ")";
47
48 ReferenceManager refman = ReferenceManager.init(null, ourName);
49
50 refman.getLogger().write(toString, Logger.SYSINIT, "coming up");
51
52 // configuration variables we require
53 int UDPListenPort = 0;
54 int TCPListenPort = 0;
55 String parentFilterName = null;
56
57 Configuration config = refman.getCM().getConfiguration(refman.getName());
58 if (config == null) {
59 throw new RuntimeException ("CRITICAL:Unable to obtain configuration" +
60 " Advise you check the i-scream log for more information.");
61 } else {
62 try {
63 UDPListenPort = Integer.parseInt(config.getProperty("Filter.UDPListenPort"));
64 TCPListenPort = Integer.parseInt(config.getProperty("Filter.TCPListenPort"));
65 parentFilterName = config.getProperty("Filter.parentFilter");
66 } catch (org.omg.CORBA.MARSHAL e) {
67 refman.getLogger().write(toString, Logger.FATAL, "required config property not present");
68 throw new RuntimeException ("CRITICAL:Unable to obtain required configuration property" +
69 " Advise you check the i-scream log for more information.");
70
71 }
72 }
73 refman.getLogger().write(toString, Logger.SYSINIT, "configured");
74 // get parent
75 Filter parentFilter = FilterHelper.narrow(refman.getCORBARef("iscream.Filter." + parentFilterName));
76
77
78
79 // FilterServant start (for inbound child filter data)
80 refman.getLogger().write(toString, Logger.DEBUG, "starting Filter Child -> Parent link for upstream parent - " + parentFilterName);
81 FilterServant filterServant = new FilterServant(parentFilter, TCPListenPort, UDPListenPort);
82 refman.bindToOrb(filterServant, "iscream.Filter." + refman.getName());
83
84 // UDL Reader start (for inbound host data)
85 refman.getLogger().write(toString, Logger.SYSINIT, "starting Filter UDP listener");
86 UDPReader udpReader = new UDPReader(UDPListenPort, parentFilter);
87 udpReader.start();
88
89 // TCP Reader start (for heartbeats)
90 refman.getLogger().write(toString, Logger.SYSINIT, "starting Filter TCP listener");
91 TCPReader tcpReader = new TCPReader(TCPListenPort, parentFilter);
92 tcpReader.start();
93
94 // start the POA off
95 // now we are running, we just need to serve
96 // so we ask the orb to block for us until it has finished
97 refman.activatePOA();
98 refman.getLogger().write(toString, Logger.SYSINIT, "started");
99 refman.getORB().run();
100 }
101
102 /**
103 * A simple method to print the usage of this class.
104 * It never returns, but instead exits to the system
105 * with a value 1, to indicate the system did not start
106 * properly.
107 */
108 public static void usage() {
109 System.out.println("USAGE: java FilterMain <name>");
110 System.out.println("WHERE <name>:");
111 System.out.println(" The unique identifier for the Filter in the system.");
112 System.exit(1);
113 }
114
115 //---CONSTRUCTORS---
116
117 //---PUBLIC METHODS---
118
119 //---PRIVATE METHODS---
120
121 //---ACCESSOR/MUTATOR METHODS---
122
123 //---ATTRIBUTES---
124
125 //---STATIC ATTRIBUTES---
126
127 }