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.20
Committed: Sun Jan 28 06:03:58 2001 UTC (23 years, 3 months ago) by tdb
Branch: MAIN
Changes since 1.19: +9 -12 lines
Log Message:
A tidy up of the configuration getting section.

File Contents

# Content
1 //---PACKAGE DECLARATION---
2 package uk.ac.ukc.iscream.filter;
3
4 //---IMPORTS---
5 import uk.ac.ukc.iscream.util.*;
6 import uk.ac.ukc.iscream.core.*;
7 import uk.ac.ukc.iscream.componentmanager.*;
8 import uk.ac.ukc.iscream.filter.*;
9
10 /**
11 * A Filter Startup Class
12 * A filter is an iscream component.
13 *
14 * @author $Author: tdb1 $
15 * @version $Id: FilterMain.java,v 1.19 2001/01/18 23:17:58 tdb1 Exp $
16 */
17 public class FilterMain implements Component {
18
19 //---FINAL ATTRIBUTES---
20
21 /**
22 * The current CVS revision of this class
23 */
24 public static final String REVISION = "$Revision: 1.19 $";
25
26 //---STATIC METHODS---
27
28 //---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
48 // configuration variables we require
49 int UDPListenPort = 0;
50 int TCPListenPort = 0;
51 String parentFilterName = null;
52
53 Configuration config = _refman.getCM().getConfiguration(FilterMain.NAME);
54 if (config == null) {
55 throw new ComponentStartException("Unable to obtain configuration for component");
56 }
57 else {
58 try {
59 // get the configuration properties we need
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 throw new ComponentStartException("Unable to obtain requried configuration property for component");
65 }
66 }
67
68 _logger.write(toString(), Logger.SYSINIT, "configured");
69
70 // get parent
71 Filter parentFilter = FilterHelper.narrow(_refman.getCORBARef("iscream.Filter." + parentFilterName));
72
73 // setup a queue
74 Queue queue = new Queue();
75
76 // Start a filter thread
77 _logger.write(toString(), Logger.SYSINIT, "starting Filter Thread / Queue consumer");
78 FilterThread filterThread = new FilterThread(queue, parentFilter);
79 filterThread.start();
80
81 // FilterServant start (for inbound child filter data)
82 _logger.write(toString(), Logger.DEBUG, "starting Filter Child -> Parent link for upstream parent - " + parentFilterName);
83 FilterServant filterServant = new FilterServant(TCPListenPort, UDPListenPort, queue);
84 _refman.bindToOrb(filterServant, "iscream.Filter." + FilterMain.NAME);
85
86 // UDL Reader start (for inbound host data)
87 _logger.write(toString(), Logger.SYSINIT, "starting Filter UDP listener");
88 UDPReader udpReader = new UDPReader(UDPListenPort, queue);
89 udpReader.start();
90
91 // TCP Reader start (for heartbeats)
92 _logger.write(toString(), Logger.SYSINIT, "starting Filter TCP listener");
93 TCPReader tcpReader = new TCPReader(TCPListenPort, queue);
94 tcpReader.start();
95
96 _logger.write(toString(), Logger.SYSINIT, "started");
97 }
98
99 /**
100 * Overrides the {@link java.lang.Object#toString() Object.toString()}
101 * method to provide clean logging (every class should have this).
102 *
103 * This uses the uk.ac.ukc.iscream.util.NameFormat class
104 * to format the toString()
105 *
106 * @return the name of this class and its CVS revision
107 */
108 public String toString() {
109 return FormatName.getName(
110 NAME,
111 getClass().getName(),
112 REVISION);
113 }
114
115 //---PRIVATE METHODS---
116
117 //---ACCESSOR/MUTATOR METHODS---
118
119 //---ATTRIBUTES---
120
121 /**
122 * This holds a reference to the
123 * system logger that is being used.
124 */
125 private Logger _logger = ReferenceManager.getInstance().getLogger();
126
127 /**
128 * A reference to the reference manager in use
129 */
130 private ReferenceManager _refman = ReferenceManager.getInstance();
131
132 //---STATIC ATTRIBUTES---
133
134 /**
135 * The friendly name for this component, used by
136 * all related classes.
137 * This is set from the configuration.
138 */
139 public static String NAME;
140
141 }