1 |
+ |
|
2 |
|
//---PACKAGE DECLARATION--- |
3 |
|
package uk.ac.ukc.iscream.rootfilter; |
4 |
|
|
38 |
|
* This starts the Root Filter for the system |
39 |
|
*/ |
40 |
|
public void start() throws ComponentStartException { |
41 |
< |
|
41 |
> |
// get references to key objects |
42 |
> |
_refman = ReferenceManager.getInstance(); |
43 |
> |
_logger = ReferenceManager.getInstance().getLogger(); |
44 |
> |
|
45 |
|
_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; |
46 |
|
|
47 |
< |
Configuration config = _refman.getCM().getConfiguration("RootFilter"); |
48 |
< |
if (config == null) { |
49 |
< |
throw new ComponentStartException("Unable to obtain configuration for component"); |
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 |
|
} |
57 |
< |
else { |
58 |
< |
try { |
59 |
< |
// get the configuration properties we need |
60 |
< |
ourName = config.getProperty("RootFilter.name"); |
61 |
< |
realInterface = config.getProperty("RootFilter.realtimeInterfaceName"); |
62 |
< |
dbInterface = config.getProperty("RootFilter.dbInterfaceName"); |
63 |
< |
} catch (org.omg.CORBA.MARSHAL e) { |
64 |
< |
throw new ComponentStartException("Unable to obtain requried configuration property for component"); |
65 |
< |
} |
57 |
> |
|
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 |
|
} |
68 |
|
|
63 |
– |
// now we have the name of the Root Filter we set it |
64 |
– |
NAME = ourName; |
65 |
– |
|
66 |
– |
_logger.write(toString(), Logger.SYSINIT, "configured"); |
67 |
– |
|
69 |
|
ClientInterface ciReal = null, ciDB = null; |
70 |
|
// get reference to the client interfaces - the real time one |
71 |
|
if (realInterface != null) { |
75 |
|
if (dbInterface != null) { |
76 |
|
ciDB = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + dbInterface)); |
77 |
|
} |
78 |
< |
|
78 |
> |
|
79 |
> |
// setup a queue |
80 |
|
Queue queue = new Queue(); |
79 |
– |
// startup a monitor on this queue, every minute |
80 |
– |
queue.startMonitor(60*1000, NAME); |
81 |
|
|
82 |
+ |
// 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 |
+ |
|
92 |
|
if (realInterface == null) { |
93 |
|
_logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + dbInterface); |
94 |
|
CIWrapper c = new CIWrapper(ciDB, queue); |
141 |
|
* This holds a reference to the |
142 |
|
* system logger that is being used. |
143 |
|
*/ |
144 |
< |
private Logger _logger = ReferenceManager.getInstance().getLogger(); |
144 |
> |
private Logger _logger; |
145 |
|
|
146 |
|
/** |
147 |
|
* A reference to the reference manager in use |
148 |
|
*/ |
149 |
< |
private ReferenceManager _refman = ReferenceManager.getInstance(); |
149 |
> |
private ReferenceManager _refman; |
150 |
|
|
151 |
|
//---STATIC ATTRIBUTES--- |
152 |
|
|