1 |
tdb |
1.1 |
//---PACKAGE DECLARATION--- |
2 |
|
|
package uk.ac.ukc.iscream.rootfilter; |
3 |
|
|
|
4 |
|
|
//---IMPORTS--- |
5 |
|
|
import uk.ac.ukc.iscream.core.*; |
6 |
tdb |
1.4 |
import uk.ac.ukc.iscream.componentmanager.*; |
7 |
tdb |
1.1 |
import uk.ac.ukc.iscream.clientinterface.*; |
8 |
|
|
import uk.ac.ukc.iscream.util.*; |
9 |
|
|
|
10 |
|
|
/** |
11 |
|
|
* A ClientInterface wrapper - the CI objects are pushed data, |
12 |
|
|
* yet data is pulled from the queue. This will sit inbetween |
13 |
|
|
* for now, until the CI design is changed. |
14 |
|
|
* |
15 |
tdb |
1.2 |
* @author $Author: tdb1 $ |
16 |
tdb |
1.1 |
* @version $Id $ |
17 |
|
|
*/ |
18 |
|
|
public class CIWrapper extends Thread { |
19 |
|
|
|
20 |
|
|
//---FINAL ATTRIBUTES--- |
21 |
|
|
|
22 |
|
|
/** |
23 |
|
|
* The current CVS revision of this class |
24 |
|
|
*/ |
25 |
tdb |
1.8 |
public final String REVISION = "$Revision: 1.7 $"; |
26 |
tdb |
1.1 |
|
27 |
|
|
//---STATIC METHODS--- |
28 |
|
|
|
29 |
|
|
//---CONSTRUCTORS--- |
30 |
|
|
|
31 |
|
|
/** |
32 |
|
|
* Sets up the wrapper, with a single destination and a queue. |
33 |
|
|
* |
34 |
|
|
* @param destination the client interface to send the xml to |
35 |
|
|
* @param queue a reference to a queue to use |
36 |
|
|
*/ |
37 |
|
|
public CIWrapper(ClientInterface destination, Queue queue){ |
38 |
tdb |
1.7 |
// set the Thread name |
39 |
|
|
setName("rootfilter.CIWrapper"); |
40 |
|
|
|
41 |
tdb |
1.1 |
_destination = destination; |
42 |
|
|
_queue = queue; |
43 |
tdb |
1.5 |
_queueID = queue.getQueue(); |
44 |
tdb |
1.1 |
} |
45 |
|
|
|
46 |
|
|
//---PUBLIC METHODS--- |
47 |
|
|
|
48 |
|
|
/** |
49 |
|
|
* start the thread and thus gets and sends data |
50 |
|
|
*/ |
51 |
|
|
public void run() { |
52 |
tdb |
1.3 |
String xml = null; |
53 |
tdb |
1.1 |
while(true) { |
54 |
|
|
try { |
55 |
tdb |
1.6 |
xml = (String) _queue.get(_queueID); |
56 |
tdb |
1.1 |
} |
57 |
|
|
catch (InvalidQueueException e) { |
58 |
|
|
_logger.write(toString(), Logger.ERROR, "Queue error: "+e); |
59 |
|
|
} |
60 |
|
|
_destination.receiveXML(xml); |
61 |
|
|
} |
62 |
|
|
} |
63 |
|
|
|
64 |
|
|
/** |
65 |
|
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
66 |
|
|
* method to provide clean logging (every class should have this). |
67 |
|
|
* |
68 |
tdb |
1.8 |
* This uses the uk.ac.ukc.iscream.util.NameFormat class |
69 |
|
|
* to format the toString() |
70 |
|
|
* |
71 |
tdb |
1.1 |
* @return the name of this class and its CVS revision |
72 |
|
|
*/ |
73 |
|
|
public String toString() { |
74 |
tdb |
1.8 |
return FormatName.getName( |
75 |
|
|
_name, |
76 |
|
|
getClass().getName(), |
77 |
|
|
REVISION); |
78 |
tdb |
1.1 |
} |
79 |
|
|
|
80 |
|
|
//---PRIVATE METHODS--- |
81 |
|
|
|
82 |
|
|
//---ACCESSOR/MUTATOR METHODS--- |
83 |
|
|
|
84 |
|
|
//---ATTRIBUTES--- |
85 |
|
|
|
86 |
|
|
/** |
87 |
|
|
* A reference to a Queue object. |
88 |
|
|
*/ |
89 |
|
|
private Queue _queue; |
90 |
tdb |
1.5 |
|
91 |
|
|
/** |
92 |
|
|
* Our Queue id. |
93 |
|
|
*/ |
94 |
|
|
private int _queueID; |
95 |
tdb |
1.1 |
|
96 |
|
|
/** |
97 |
|
|
* the interface this thread is sending data to |
98 |
|
|
*/ |
99 |
|
|
private ClientInterface _destination; |
100 |
|
|
|
101 |
|
|
/** |
102 |
|
|
* This is the friendly identifier of the |
103 |
|
|
* component this class is running in. |
104 |
|
|
* eg, a Filter may be called "filter1", |
105 |
|
|
* If this class does not have an owning |
106 |
|
|
* component, a name from the configuration |
107 |
|
|
* can be placed here. This name could also |
108 |
|
|
* be changed to null for utility classes. |
109 |
|
|
*/ |
110 |
|
|
private String _name = RootFilter.NAME; |
111 |
|
|
|
112 |
|
|
/** |
113 |
|
|
* This holds a reference to the |
114 |
|
|
* system logger that is being used. |
115 |
|
|
*/ |
116 |
|
|
private Logger _logger = ReferenceManager.getInstance().getLogger(); |
117 |
|
|
|
118 |
|
|
//---STATIC ATTRIBUTES--- |
119 |
|
|
|
120 |
|
|
} |