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.19
Committed: Thu Jan 18 23:17:58 2001 UTC (23 years, 4 months ago) by tdb
Branch: MAIN
Changes since 1.18: +5 -4 lines
Log Message:
Changes to reflect move of Component, ComponentStartException, and the
ReferenceManager from util to componentmanager.

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