ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/rootfilter/RootFilter.java
Revision: 1.25
Committed: Wed Feb 21 19:11:31 2001 UTC (23 years, 2 months ago) by tdb
Branch: MAIN
Changes since 1.24: +6 -3 lines
Log Message:
Modification to the Queue system;
- interval of monitor is now configurable.
- attempt to identify each Queue better, although this is still hard.

File Contents

# Content
1 //---PACKAGE DECLARATION---
2 package uk.ac.ukc.iscream.rootfilter;
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.clientinterface.*;
9
10 /**
11 * The root filter is what all filters talk to
12 * Hosts cannot talk to this implementation of a filter.
13 * It provides hooks to all data interfaces for the system
14 * namely the client interface and the db interface.
15 * This is an i-scream component that starts the
16 * RootFilter services.
17 *
18 * @author $Author: tdb1 $
19 * @version $Id: RootFilter.java,v 1.24 2001/02/12 02:22:19 tdb1 Exp $
20 */
21 public class RootFilter implements Component {
22
23 //---FINAL ATTRIBUTES---
24
25 /**
26 * The current CVS revision of this class
27 */
28 public static final String REVISION = "$Revision: 1.24 $";
29
30 //---STATIC METHODS---
31
32 //---CONSTRUCTORS---
33
34 //---PUBLIC METHODS---
35
36 /**
37 * This starts the Root Filter for the system
38 */
39 public void start() throws ComponentStartException {
40
41 _logger.write(toString(), Logger.SYSINIT, "coming up");
42
43 // configuration variables we require
44 String ourName = null;
45 String realInterface = null;
46 String dbInterface = null;
47 int queueMonitorInterval = 0;
48
49 Configuration config = _refman.getCM().getConfiguration("RootFilter");
50 if (config == null) {
51 throw new ComponentStartException("Unable to obtain configuration for component");
52 }
53 else {
54 try {
55 // get the configuration properties we need
56 ourName = config.getProperty("RootFilter.name");
57 realInterface = config.getProperty("RootFilter.realtimeInterfaceName");
58 dbInterface = config.getProperty("RootFilter.dbInterfaceName");
59 queueMonitorInterval = Integer.parseInt(config.getProperty("Queue.MonitorInterval"));
60 } catch (org.omg.CORBA.MARSHAL e) {
61 throw new ComponentStartException("Unable to obtain requried configuration property for component");
62 }
63 }
64
65 // now we have the name of the Root Filter we set it
66 NAME = ourName;
67
68 _logger.write(toString(), Logger.SYSINIT, "configured");
69
70 ClientInterface ciReal = null, ciDB = null;
71 // get reference to the client interfaces - the real time one
72 if (realInterface != null) {
73 ciReal = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + realInterface));
74 }
75 // get reference to the client interfaces - and the db one
76 if (dbInterface != null) {
77 ciDB = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + dbInterface));
78 }
79
80 Queue queue = new Queue();
81 // startup a monitor on this queue, every minute
82 String queueName = NAME + " RootFilter";
83 queue.startMonitor(queueMonitorInterval*1000, queueName);
84
85 if (realInterface == null) {
86 _logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + dbInterface);
87 CIWrapper c = new CIWrapper(ciDB, queue);
88 c.start();
89 } else if (dbInterface == null) {
90 _logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + realInterface);
91 CIWrapper c = new CIWrapper(ciReal, queue);
92 c.start();
93 } else {
94 _logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + realInterface + " & " + dbInterface);
95 CIWrapper c = new CIWrapper(ciReal, queue);
96 c.start();
97 c = new CIWrapper(ciDB, queue);
98 c.start();
99 }
100
101 // RootFilterServant start (for inbound child filter data)
102 _logger.write(toString(), Logger.DEBUG, "starting Root Filter");
103 RootFilterServant filterServant = new RootFilterServant(queue);
104 // bind to the naming service as a filter
105 _refman.bindToOrb(filterServant, "iscream.Filter." + RootFilter.NAME);
106
107 _logger.write(toString(), Logger.SYSINIT, "started");
108
109 }
110
111 /**
112 * Overrides the {@link java.lang.Object#toString() Object.toString()}
113 * method to provide clean logging (every class should have this).
114 *
115 * This uses the uk.ac.ukc.iscream.util.NameFormat class
116 * to format the toString()
117 *
118 * @return the name of this class and its CVS revision
119 */
120 public String toString() {
121 return FormatName.getName(
122 NAME,
123 getClass().getName(),
124 REVISION);
125 }
126
127 //---PRIVATE METHODS---
128
129 //---ACCESSOR/MUTATOR METHODS---
130
131 //---ATTRIBUTES---
132
133 /**
134 * This holds a reference to the
135 * system logger that is being used.
136 */
137 private Logger _logger = ReferenceManager.getInstance().getLogger();
138
139 /**
140 * A reference to the reference manager in use
141 */
142 private ReferenceManager _refman = ReferenceManager.getInstance();
143
144 //---STATIC ATTRIBUTES---
145
146 /**
147 * The friendly name for this component, used by
148 * all related classes.
149 * This is set from the configuration.
150 */
151 public static String NAME;
152
153 }