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 |
|
|
47 |
|
|
48 |
|
Configuration config = _refman.getCM().getConfiguration("RootFilter"); |
49 |
|
if (config == null) { |
50 |
< |
System.err.println("CRITICAL:Unable to obtain configuration" + |
51 |
< |
"\n Advise you check the i-scream log for more information."); |
52 |
< |
_logger.write(toString(), Logger.FATAL, "ERROR - unable to obtain configuration"); |
52 |
< |
System.exit(1); |
53 |
< |
} else { |
50 |
> |
throw new ComponentStartException("Unable to obtain configuration for component"); |
51 |
> |
} |
52 |
> |
else { |
53 |
|
try { |
54 |
+ |
// get the configuration properties we need |
55 |
|
ourName = config.getProperty("RootFilter.name"); |
56 |
|
realInterface = config.getProperty("RootFilter.realtimeInterfaceName"); |
57 |
|
dbInterface = config.getProperty("RootFilter.dbInterfaceName"); |
58 |
|
} catch (org.omg.CORBA.MARSHAL e) { |
59 |
< |
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); |
59 |
> |
throw new ComponentStartException("Unable to obtain requried configuration property for component"); |
60 |
|
} |
61 |
|
} |
62 |
+ |
|
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 |
< |
|
67 |
> |
|
68 |
> |
ClientInterface ciReal = null, ciDB = null; |
69 |
|
// get reference to the client interfaces - the real time one |
70 |
< |
ClientInterface ciReal = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + realInterface)); |
70 |
> |
if (realInterface != null) { |
71 |
> |
ciReal = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + realInterface)); |
72 |
> |
} |
73 |
|
// get reference to the client interfaces - and the db one |
74 |
< |
ClientInterface ciDB = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + dbInterface)); |
75 |
< |
_logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + realInterface + " & " + dbInterface); |
74 |
> |
if (dbInterface != null) { |
75 |
> |
ciDB = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + dbInterface)); |
76 |
> |
} |
77 |
|
|
78 |
< |
ClientInterface[] clientInterfaces = {ciReal, ciDB}; |
78 |
> |
Queue queue = new Queue(); |
79 |
|
|
80 |
+ |
if (realInterface == null) { |
81 |
+ |
_logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + dbInterface); |
82 |
+ |
CIWrapper c = new CIWrapper(ciDB, queue); |
83 |
+ |
c.start(); |
84 |
+ |
} else if (dbInterface == null) { |
85 |
+ |
_logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + realInterface); |
86 |
+ |
CIWrapper c = new CIWrapper(ciReal, queue); |
87 |
+ |
c.start(); |
88 |
+ |
} else { |
89 |
+ |
_logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + realInterface + " & " + dbInterface); |
90 |
+ |
CIWrapper c = new CIWrapper(ciReal, queue); |
91 |
+ |
c.start(); |
92 |
+ |
c = new CIWrapper(ciDB, queue); |
93 |
+ |
c.start(); |
94 |
+ |
} |
95 |
+ |
|
96 |
|
// RootFilterServant start (for inbound child filter data) |
97 |
|
_logger.write(toString(), Logger.DEBUG, "starting Root Filter"); |
98 |
< |
RootFilterServant filterServant = new RootFilterServant(clientInterfaces); |
98 |
> |
RootFilterServant filterServant = new RootFilterServant(queue); |
99 |
|
// bind to the naming service as a filter |
100 |
< |
_refman.bindToOrb(filterServant, "iscream.Filter." + _name); |
100 |
> |
_refman.bindToOrb(filterServant, "iscream.Filter." + RootFilter.NAME); |
101 |
|
|
102 |
|
_logger.write(toString(), Logger.SYSINIT, "started"); |
103 |
+ |
|
104 |
|
} |
105 |
|
|
106 |
|
/** |
114 |
|
*/ |
115 |
|
public String toString() { |
116 |
|
return FormatName.getName( |
117 |
< |
_name, |
117 |
> |
NAME, |
118 |
|
getClass().getName(), |
119 |
|
REVISION); |
120 |
|
} |
124 |
|
//---ACCESSOR/MUTATOR METHODS--- |
125 |
|
|
126 |
|
//---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; |
127 |
|
|
128 |
|
/** |
129 |
|
* This holds a reference to the |