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