1 |
tdb |
1.1 |
//---PACKAGE DECLARATION--- |
2 |
tdb |
1.3 |
package uk.ac.ukc.iscream.rootfilter; |
3 |
tdb |
1.1 |
|
4 |
|
|
//---IMPORTS--- |
5 |
ajm |
1.5 |
import uk.ac.ukc.iscream.util.*; |
6 |
tdb |
1.1 |
import uk.ac.ukc.iscream.core.*; |
7 |
ajm |
1.8 |
import uk.ac.ukc.iscream.clientinterface.*; |
8 |
tdb |
1.1 |
|
9 |
|
|
/** |
10 |
ajm |
1.10 |
* The root filter is what all filters talk to |
11 |
|
|
* Hosts cannot talk to this implementation of a filter. |
12 |
|
|
* It provides hooks to all data interfaces for the system |
13 |
|
|
* namely the client interface and the db interface. |
14 |
|
|
* This is an i-scream component that starts the |
15 |
|
|
* RootFilter services. |
16 |
tdb |
1.1 |
* |
17 |
ajm |
1.5 |
* @author $Author: ajm4 $ |
18 |
tdb |
1.15 |
* @version $Id: RootFilter.java,v 1.14 2000/12/13 15:46:22 ajm4 Exp $ |
19 |
tdb |
1.1 |
*/ |
20 |
ajm |
1.10 |
public class RootFilter implements uk.ac.ukc.iscream.util.Component { |
21 |
tdb |
1.1 |
|
22 |
|
|
//---FINAL ATTRIBUTES--- |
23 |
|
|
|
24 |
|
|
/** |
25 |
|
|
* The current CVS revision of this class |
26 |
|
|
*/ |
27 |
tdb |
1.15 |
public static final String REVISION = "$Revision: 1.14 $"; |
28 |
ajm |
1.10 |
|
29 |
tdb |
1.1 |
//---STATIC METHODS--- |
30 |
|
|
|
31 |
ajm |
1.10 |
//---CONSTRUCTORS--- |
32 |
|
|
|
33 |
|
|
//---PUBLIC METHODS--- |
34 |
ajm |
1.5 |
|
35 |
ajm |
1.10 |
/** |
36 |
|
|
* This starts the Root Filter for the system |
37 |
|
|
*/ |
38 |
|
|
public void start() throws ComponentStartException { |
39 |
ajm |
1.5 |
|
40 |
ajm |
1.10 |
_logger.write(toString(), Logger.SYSINIT, "coming up"); |
41 |
ajm |
1.5 |
|
42 |
|
|
// configuration variables we require |
43 |
|
|
String ourName = null; |
44 |
ajm |
1.8 |
String realInterface = null; |
45 |
|
|
String dbInterface = null; |
46 |
ajm |
1.5 |
|
47 |
ajm |
1.10 |
Configuration config = _refman.getCM().getConfiguration("RootFilter"); |
48 |
ajm |
1.5 |
if (config == null) { |
49 |
ajm |
1.10 |
System.err.println("CRITICAL:Unable to obtain configuration" + |
50 |
|
|
"\n Advise you check the i-scream log for more information."); |
51 |
|
|
_logger.write(toString(), Logger.FATAL, "ERROR - unable to obtain configuration"); |
52 |
|
|
System.exit(1); |
53 |
ajm |
1.5 |
} else { |
54 |
|
|
try { |
55 |
ajm |
1.8 |
ourName = config.getProperty("RootFilter.name"); |
56 |
|
|
realInterface = config.getProperty("RootFilter.realtimeInterfaceName"); |
57 |
|
|
dbInterface = config.getProperty("RootFilter.dbInterfaceName"); |
58 |
ajm |
1.5 |
} catch (org.omg.CORBA.MARSHAL e) { |
59 |
ajm |
1.10 |
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); |
63 |
ajm |
1.5 |
} |
64 |
tdb |
1.1 |
} |
65 |
ajm |
1.5 |
// now we have the name of the Root Filter we set it |
66 |
ajm |
1.10 |
NAME = ourName; |
67 |
|
|
|
68 |
|
|
_logger.write(toString(), Logger.SYSINIT, "configured"); |
69 |
ajm |
1.13 |
|
70 |
|
|
ClientInterface ciReal = null, ciDB = null; |
71 |
ajm |
1.8 |
// get reference to the client interfaces - the real time one |
72 |
ajm |
1.11 |
if (realInterface != null) { |
73 |
ajm |
1.13 |
ciReal = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + realInterface)); |
74 |
ajm |
1.11 |
} |
75 |
ajm |
1.10 |
// get reference to the client interfaces - and the db one |
76 |
ajm |
1.11 |
if (dbInterface != null) { |
77 |
ajm |
1.13 |
ciDB = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + dbInterface)); |
78 |
ajm |
1.11 |
} |
79 |
tdb |
1.15 |
|
80 |
|
|
Queue queue = new Queue(); |
81 |
|
|
|
82 |
ajm |
1.11 |
if (realInterface == null) { |
83 |
|
|
_logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + dbInterface); |
84 |
tdb |
1.15 |
CIWrapper c = new CIWrapper(ciDB, queue); |
85 |
|
|
c.start(); |
86 |
ajm |
1.11 |
} else if (dbInterface == null) { |
87 |
|
|
_logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + realInterface); |
88 |
tdb |
1.15 |
CIWrapper c = new CIWrapper(ciReal, queue); |
89 |
|
|
c.start(); |
90 |
ajm |
1.11 |
} else { |
91 |
|
|
_logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + realInterface + " & " + dbInterface); |
92 |
tdb |
1.15 |
CIWrapper c = new CIWrapper(ciReal, queue); |
93 |
|
|
c.start(); |
94 |
|
|
c = new CIWrapper(ciDB, queue); |
95 |
|
|
c.start(); |
96 |
ajm |
1.11 |
} |
97 |
tdb |
1.15 |
|
98 |
ajm |
1.8 |
// RootFilterServant start (for inbound child filter data) |
99 |
ajm |
1.10 |
_logger.write(toString(), Logger.DEBUG, "starting Root Filter"); |
100 |
tdb |
1.15 |
RootFilterServant filterServant = new RootFilterServant(queue); |
101 |
ajm |
1.8 |
// bind to the naming service as a filter |
102 |
ajm |
1.14 |
_refman.bindToOrb(filterServant, "iscream.Filter." + RootFilter.NAME); |
103 |
tdb |
1.1 |
|
104 |
ajm |
1.10 |
_logger.write(toString(), Logger.SYSINIT, "started"); |
105 |
tdb |
1.1 |
} |
106 |
ajm |
1.10 |
|
107 |
|
|
/** |
108 |
|
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
109 |
|
|
* method to provide clean logging (every class should have this). |
110 |
|
|
* |
111 |
|
|
* This uses the uk.ac.ukc.iscream.util.NameFormat class |
112 |
|
|
* to format the toString() |
113 |
|
|
* |
114 |
|
|
* @return the name of this class and its CVS revision |
115 |
|
|
*/ |
116 |
|
|
public String toString() { |
117 |
|
|
return FormatName.getName( |
118 |
ajm |
1.14 |
NAME, |
119 |
ajm |
1.10 |
getClass().getName(), |
120 |
|
|
REVISION); |
121 |
tdb |
1.1 |
} |
122 |
|
|
|
123 |
|
|
//---PRIVATE METHODS--- |
124 |
|
|
|
125 |
|
|
//---ACCESSOR/MUTATOR METHODS--- |
126 |
|
|
|
127 |
|
|
//---ATTRIBUTES--- |
128 |
ajm |
1.10 |
|
129 |
|
|
/** |
130 |
|
|
* This holds a reference to the |
131 |
|
|
* system logger that is being used. |
132 |
|
|
*/ |
133 |
|
|
private Logger _logger = ReferenceManager.getInstance().getLogger(); |
134 |
|
|
|
135 |
|
|
/** |
136 |
|
|
* A reference to the reference manager in use |
137 |
|
|
*/ |
138 |
|
|
private ReferenceManager _refman = ReferenceManager.getInstance(); |
139 |
|
|
|
140 |
tdb |
1.1 |
//---STATIC ATTRIBUTES--- |
141 |
ajm |
1.10 |
|
142 |
|
|
/** |
143 |
|
|
* The friendly name for this component, used by |
144 |
|
|
* all related classes. |
145 |
|
|
* This is set from the configuration. |
146 |
|
|
*/ |
147 |
|
|
public static String NAME; |
148 |
tdb |
1.1 |
|
149 |
ajm |
1.5 |
} |