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.14
Committed: Thu Nov 30 02:38:09 2000 UTC (23 years, 5 months ago) by ajm
Branch: MAIN
Changes since 1.13: +3 -3 lines
Log Message:
Changed package structure
uk.ac.ukc.iscream.refman and xml -> uk.ac.ukc.iscream.util

File Contents

# User Rev Content
1 tdb 1.1 //---PACKAGE DECLARATION---
2 tdb 1.11 package uk.ac.ukc.iscream.filter;
3 tdb 1.1
4     //---IMPORTS---
5 ajm 1.14 import uk.ac.ukc.iscream.util.*;
6 tdb 1.1 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 ajm 1.13 * @author $Author: ajm4 $
16 ajm 1.14 * @version $Id: FilterMain.java,v 1.13 2000/11/30 02:18:51 ajm4 Exp $
17 tdb 1.1 */
18     class FilterMain {
19    
20     //---FINAL ATTRIBUTES---
21    
22     /**
23     * The current CVS revision of this class
24     */
25 ajm 1.14 public static final String REVISION = "$Revision: 1.13 $";
26 tdb 1.1
27     //---STATIC METHODS---
28    
29     public static void main(String[] args) {
30 ajm 1.13 // ***************************************
31     // VERY TEMPORARY - will find a better way
32 tdb 1.1 System.setProperty("org.omg.CORBA.ORBClass","jacorb.orb.ORB");
33     System.setProperty("org.omg.CORBA.ORBSingletonClass","jacorb.orb.ORBSingleton");
34 ajm 1.13 // ***************************************
35    
36 tdb 1.1 // 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 ajm 1.13
48     ReferenceManager refman = ReferenceManager.init(null, ourName);
49 tdb 1.1
50 ajm 1.13 refman.getLogger().write(toString, Logger.SYSINIT, "coming up");
51 tdb 1.1
52 ajm 1.13 // 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 tdb 1.2 }
72 tdb 1.1 }
73 ajm 1.13 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 tdb 1.1 }
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 pjm2 1.7 System.out.println("USAGE: java FilterMain <name>");
110 tdb 1.1 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 pjm2 1.4 }