1 |
+ |
|
2 |
|
//---PACKAGE DECLARATION--- |
3 |
< |
package uk.ac.ukc.iscream.rootfilter; |
3 |
> |
package uk.org.iscream.rootfilter; |
4 |
|
|
5 |
|
//---IMPORTS--- |
6 |
< |
import uk.ac.ukc.iscream.util.*; |
7 |
< |
import uk.ac.ukc.iscream.core.*; |
8 |
< |
import uk.ac.ukc.iscream.componentmanager.*; |
9 |
< |
import uk.ac.ukc.iscream.clientinterface.*; |
6 |
> |
import uk.org.iscream.util.*; |
7 |
> |
import uk.org.iscream.core.*; |
8 |
> |
import uk.org.iscream.componentmanager.*; |
9 |
> |
import uk.org.iscream.clientinterface.*; |
10 |
|
|
11 |
|
/** |
12 |
|
* The root filter is what all filters talk to |
39 |
|
*/ |
40 |
|
public void start() throws ComponentStartException { |
41 |
|
// get references to key objects |
42 |
< |
_refman = ReferenceManager.getInstance(); |
42 |
< |
_logger = ReferenceManager.getInstance().getLogger(); |
42 |
> |
_logger = _refman.getLogger(); |
43 |
|
|
44 |
|
_logger.write(toString(), Logger.SYSINIT, "coming up"); |
45 |
– |
|
46 |
– |
// configuration variables we require |
47 |
– |
String ourName = null; |
48 |
– |
String realInterface = null; |
49 |
– |
String dbInterface = null; |
50 |
– |
int queueMonitorInterval = 0; |
45 |
|
|
46 |
< |
Configuration config = _refman.getCM().getConfiguration("RootFilter"); |
47 |
< |
if (config == null) { |
48 |
< |
throw new ComponentStartException("Unable to obtain configuration for component"); |
46 |
> |
ConfigurationProxy cp = ConfigurationProxy.getInstance(); |
47 |
> |
String configName = "RootFilter"; |
48 |
> |
|
49 |
> |
// set the name of the root filter |
50 |
> |
try { |
51 |
> |
NAME = cp.getProperty(configName, "RootFilter.name"); |
52 |
> |
} catch (PropertyNotFoundException e) { |
53 |
> |
NAME = null; |
54 |
> |
_logger.write(toString(), Logger.WARNING, "RootFilter name not set: "+e); |
55 |
|
} |
56 |
< |
else { |
57 |
< |
try { |
58 |
< |
// get the configuration properties we need |
59 |
< |
ourName = config.getProperty("RootFilter.name"); |
60 |
< |
realInterface = config.getProperty("RootFilter.realtimeInterfaceName"); |
61 |
< |
dbInterface = config.getProperty("RootFilter.dbInterfaceName"); |
62 |
< |
queueMonitorInterval = Integer.parseInt(config.getProperty("Queue.MonitorInterval")); |
63 |
< |
} catch (org.omg.CORBA.MARSHAL e) { |
64 |
< |
throw new ComponentStartException("Unable to obtain requried configuration property for component"); |
65 |
< |
} |
56 |
> |
|
57 |
> |
// try and get the names of the ciReal and ciDB |
58 |
> |
String realInterface, dbInterface; |
59 |
> |
try { |
60 |
> |
realInterface = cp.getProperty(configName, "RootFilter.realtimeInterfaceName"); |
61 |
> |
dbInterface = cp.getProperty(configName, "RootFilter.dbInterfaceName"); |
62 |
> |
} catch (PropertyNotFoundException e) { |
63 |
> |
_logger.write(toString(), Logger.DEBUG, "Optional config not set: "+e); |
64 |
> |
realInterface = null; |
65 |
> |
dbInterface = null; |
66 |
|
} |
67 |
|
|
68 |
– |
// now we have the name of the Root Filter we set it |
69 |
– |
NAME = ourName; |
70 |
– |
|
71 |
– |
_logger.write(toString(), Logger.SYSINIT, "configured"); |
72 |
– |
|
68 |
|
ClientInterface ciReal = null, ciDB = null; |
69 |
|
// get reference to the client interfaces - the real time one |
70 |
|
if (realInterface != null) { |
74 |
|
if (dbInterface != null) { |
75 |
|
ciDB = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + dbInterface)); |
76 |
|
} |
77 |
< |
|
77 |
> |
|
78 |
> |
// setup a queue |
79 |
|
Queue queue = new Queue(); |
84 |
– |
// startup a monitor on this queue, every minute |
85 |
– |
String queueName = NAME + " RootFilter"; |
86 |
– |
queue.startMonitor(queueMonitorInterval*1000, queueName); |
80 |
|
|
81 |
+ |
// startup a monitor on this queue |
82 |
+ |
try { |
83 |
+ |
// try to get the interval, if this fails, we won't start up the monitor |
84 |
+ |
int queueMonitorInterval = Integer.parseInt(cp.getProperty(configName, "Queue.MonitorInterval")); |
85 |
+ |
String queueName = NAME + " RootFilter"; |
86 |
+ |
queue.startMonitor(queueMonitorInterval*1000, queueName); |
87 |
+ |
} catch (PropertyNotFoundException e) { |
88 |
+ |
_logger.write(toString(), Logger.WARNING, "failed to find queue monitor config, disabling. " + e); |
89 |
+ |
} |
90 |
+ |
|
91 |
|
if (realInterface == null) { |
92 |
|
_logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + dbInterface); |
93 |
|
CIWrapper c = new CIWrapper(ciDB, queue); |
115 |
|
} |
116 |
|
|
117 |
|
/** |
118 |
+ |
* Does a dependency check. Used mainly at startup to |
119 |
+ |
* see if the required dependencies (components) are up |
120 |
+ |
* and running. |
121 |
+ |
* |
122 |
+ |
* @return a boolean value, true if the depdencies are satisfied |
123 |
+ |
*/ |
124 |
+ |
public boolean depCheck() { |
125 |
+ |
try { |
126 |
+ |
org.omg.CORBA.Object obj; |
127 |
+ |
// first check the ConfigurationManager is alive |
128 |
+ |
obj = _refman.getCORBARef("iscream.ConfigurationManager"); |
129 |
+ |
// then get some info on the CLI and DBI |
130 |
+ |
ConfigurationProxy cp = ConfigurationProxy.getInstance(); |
131 |
+ |
String cli = cp.getProperty("RootFilter", "RootFilter.realtimeInterfaceName"); |
132 |
+ |
String dbi = cp.getProperty("RootFilter", "RootFilter.dbInterfaceName"); |
133 |
+ |
// finally check the CLI and DBI are alive |
134 |
+ |
obj = _refman.getCORBARef("iscream.ClientInterface." + cli); |
135 |
+ |
obj = _refman.getCORBARef("iscream.ClientInterface." + dbi); |
136 |
+ |
} catch(ComponentCORBAException e) { |
137 |
+ |
System.err.println(toString() + ": Dependency Failure: "+e); |
138 |
+ |
return false; |
139 |
+ |
} catch(PropertyNotFoundException e) { |
140 |
+ |
System.err.println(toString() + ": Unable to obtain configuration: "+e); |
141 |
+ |
return false; |
142 |
+ |
} |
143 |
+ |
// dependency check suceeded |
144 |
+ |
return true; |
145 |
+ |
} |
146 |
+ |
|
147 |
+ |
/** |
148 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
149 |
|
* method to provide clean logging (every class should have this). |
150 |
|
* |
151 |
< |
* This uses the uk.ac.ukc.iscream.util.NameFormat class |
151 |
> |
* This uses the uk.org.iscream.util.NameFormat class |
152 |
|
* to format the toString() |
153 |
|
* |
154 |
|
* @return the name of this class and its CVS revision |
175 |
|
/** |
176 |
|
* A reference to the reference manager in use |
177 |
|
*/ |
178 |
< |
private ReferenceManager _refman; |
178 |
> |
private ReferenceManager _refman = ReferenceManager.getInstance(); |
179 |
|
|
180 |
|
//---STATIC ATTRIBUTES--- |
181 |
|
|