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 |
|
/** |
18 |
|
* @author $Author$ |
19 |
|
* @version $Id$ |
20 |
|
*/ |
21 |
< |
public class RootFilter implements uk.ac.ukc.iscream.util.Component { |
21 |
> |
public class RootFilter implements Component { |
22 |
|
|
23 |
|
//---FINAL ATTRIBUTES--- |
24 |
|
|
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 |
< |
System.err.println("CRITICAL:Unable to obtain configuration" + |
52 |
< |
"\n Advise you check the i-scream log for more information."); |
53 |
< |
_logger.write(toString(), Logger.FATAL, "ERROR - unable to obtain configuration"); |
52 |
< |
System.exit(1); |
53 |
< |
} else { |
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 |
< |
System.err.println ("CRITICAL:Unable to obtain required configuration property" + |
60 |
< |
"\n Advise you check the i-scream log for more information."); |
61 |
< |
_logger.write(toString(), Logger.FATAL, "ERROR - required configuration property not present"); |
62 |
< |
System.exit(1); |
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 |
< |
|
69 |
> |
|
70 |
> |
ClientInterface ciReal = null, ciDB = null; |
71 |
|
// get reference to the client interfaces - the real time one |
72 |
< |
ClientInterface ciReal = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + realInterface)); |
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 |
< |
ClientInterface ciDB = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + dbInterface)); |
77 |
< |
_logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + realInterface + " & " + dbInterface); |
76 |
> |
if (dbInterface != null) { |
77 |
> |
ciDB = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + dbInterface)); |
78 |
> |
} |
79 |
|
|
80 |
< |
ClientInterface[] clientInterfaces = {ciReal, ciDB}; |
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(clientInterfaces); |
103 |
> |
RootFilterServant filterServant = new RootFilterServant(queue); |
104 |
|
// bind to the naming service as a filter |
105 |
< |
_refman.bindToOrb(filterServant, "iscream.Filter." + _name); |
105 |
> |
_refman.bindToOrb(filterServant, "iscream.Filter." + RootFilter.NAME); |
106 |
|
|
107 |
|
_logger.write(toString(), Logger.SYSINIT, "started"); |
108 |
+ |
|
109 |
|
} |
110 |
|
|
111 |
|
/** |
119 |
|
*/ |
120 |
|
public String toString() { |
121 |
|
return FormatName.getName( |
122 |
< |
_name, |
122 |
> |
NAME, |
123 |
|
getClass().getName(), |
124 |
|
REVISION); |
125 |
|
} |
129 |
|
//---ACCESSOR/MUTATOR METHODS--- |
130 |
|
|
131 |
|
//---ATTRIBUTES--- |
108 |
– |
|
109 |
– |
/** |
110 |
– |
* This is the friendly identifier of the |
111 |
– |
* component this class is running in. |
112 |
– |
* eg, a Filter may be called "filter1", |
113 |
– |
* If this class does not have an owning |
114 |
– |
* component, a name from the configuration |
115 |
– |
* can be placed here. This name could also |
116 |
– |
* be changed to null for utility classes. |
117 |
– |
*/ |
118 |
– |
private String _name = RootFilter.NAME; |
132 |
|
|
133 |
|
/** |
134 |
|
* This holds a reference to the |