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.16
Committed: Wed Dec 13 13:36:46 2000 UTC (23 years, 5 months ago) by ajm
Branch: MAIN
Changes since 1.15: +83 -61 lines
Log Message:
componenterized the filter and tidied all child classes, no all conform to toString standard

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    
9     /**
10     * A Filter Startup Class
11 ajm 1.16 * A filter is an iscream component.
12 tdb 1.1 *
13 ajm 1.13 * @author $Author: ajm4 $
14 ajm 1.16 * @version $Id: FilterMain.java,v 1.15 2000/11/30 03:05:47 ajm4 Exp $
15 tdb 1.1 */
16 ajm 1.16 public class FilterMain implements uk.ac.ukc.iscream.util.Component {
17 tdb 1.1
18     //---FINAL ATTRIBUTES---
19    
20     /**
21     * The current CVS revision of this class
22     */
23 ajm 1.16 public static final String REVISION = "$Revision: 1.15 $";
24 tdb 1.1
25     //---STATIC METHODS---
26    
27 ajm 1.16 //---CONSTRUCTORS---
28    
29     /**
30     * Constructs a Filter with the name given
31     *
32     * @param givenName the name
33     */
34     public FilterMain(String givenName) {
35     NAME = givenName;
36     }
37    
38     //---PUBLIC METHODS---
39    
40     /**
41     * Starts the Filter component
42     */
43     public void start() throws ComponentStartException {
44    
45     _logger.write(toString(), Logger.SYSINIT, "coming up");
46 tdb 1.1
47 ajm 1.13 // configuration variables we require
48     int UDPListenPort = 0;
49     int TCPListenPort = 0;
50     String parentFilterName = null;
51    
52 ajm 1.16 Configuration config = _refman.getCM().getConfiguration(FilterMain.NAME);
53 ajm 1.13 if (config == null) {
54 ajm 1.16 System.err.println("CRITICAL:Unable to obtain configuration" +
55     "\n Advise you check the i-scream log for more information.");
56     _logger.write(toString(), Logger.FATAL, "ERROR - unable to obtain configuration");
57     System.exit(1);
58 ajm 1.13 } else {
59     try {
60     UDPListenPort = Integer.parseInt(config.getProperty("Filter.UDPListenPort"));
61     TCPListenPort = Integer.parseInt(config.getProperty("Filter.TCPListenPort"));
62     parentFilterName = config.getProperty("Filter.parentFilter");
63     } catch (org.omg.CORBA.MARSHAL e) {
64 ajm 1.16 System.err.println ("CRITICAL:Unable to obtain required configuration property" +
65     "\n Advise you check the i-scream log for more information.");
66     _logger.write(toString(), Logger.FATAL, "ERROR - required configuration property not present");
67     System.exit(1);
68 tdb 1.2 }
69 tdb 1.1 }
70 ajm 1.16 _logger.write(toString(), Logger.SYSINIT, "configured");
71    
72 ajm 1.13 // get parent
73 ajm 1.16 Filter parentFilter = FilterHelper.narrow(_refman.getCORBARef("iscream.Filter." + parentFilterName));
74 ajm 1.13
75     // FilterServant start (for inbound child filter data)
76 ajm 1.16 _logger.write(toString(), Logger.DEBUG, "starting Filter Child -> Parent link for upstream parent - " + parentFilterName);
77 ajm 1.13 FilterServant filterServant = new FilterServant(parentFilter, TCPListenPort, UDPListenPort);
78 ajm 1.16 _refman.bindToOrb(filterServant, "iscream.Filter." + FilterMain.NAME);
79 ajm 1.13
80     // UDL Reader start (for inbound host data)
81 ajm 1.16 _logger.write(toString(), Logger.SYSINIT, "starting Filter UDP listener");
82 ajm 1.13 UDPReader udpReader = new UDPReader(UDPListenPort, parentFilter);
83     udpReader.start();
84    
85     // TCP Reader start (for heartbeats)
86 ajm 1.16 _logger.write(toString(), Logger.SYSINIT, "starting Filter TCP listener");
87 ajm 1.13 TCPReader tcpReader = new TCPReader(TCPListenPort, parentFilter);
88     tcpReader.start();
89    
90 ajm 1.16 _logger.write(toString(), Logger.SYSINIT, "started");
91 tdb 1.1 }
92    
93 ajm 1.16 /**
94     * Overrides the {@link java.lang.Object#toString() Object.toString()}
95     * method to provide clean logging (every class should have this).
96     *
97     * This uses the uk.ac.ukc.iscream.util.NameFormat class
98     * to format the toString()
99     *
100     * @return the name of this class and its CVS revision
101     */
102     public String toString() {
103     return FormatName.getName(
104     _name,
105     getClass().getName(),
106     REVISION);
107 tdb 1.1 }
108    
109     //---PRIVATE METHODS---
110    
111     //---ACCESSOR/MUTATOR METHODS---
112    
113     //---ATTRIBUTES---
114    
115 ajm 1.16 /**
116     * This is the friendly identifier of the
117     * component this class is running in.
118     * eg, a Filter may be called "filter1",
119     * If this class does not have an owning
120     * component, a name from the configuration
121     * can be placed here. This name could also
122     * be changed to null for utility classes.
123     */
124     private String _name = FilterMain.NAME;
125    
126     /**
127     * This holds a reference to the
128     * system logger that is being used.
129     */
130     private Logger _logger = ReferenceManager.getInstance().getLogger();
131    
132     /**
133     * A reference to the reference manager in use
134     */
135     private ReferenceManager _refman = ReferenceManager.getInstance();
136    
137 tdb 1.1 //---STATIC ATTRIBUTES---
138 ajm 1.16
139     /**
140     * The friendly name for this component, used by
141     * all related classes.
142     * This is set from the configuration.
143     */
144     public static String NAME;
145 tdb 1.1
146 pjm2 1.4 }