1 |
|
//---PACKAGE DECLARATION--- |
2 |
< |
package uk.ac.ukc.iscream.conient; |
2 |
> |
package uk.org.iscream.conient; |
3 |
|
|
4 |
|
//---IMPORTS--- |
5 |
|
import java.io.*; |
6 |
< |
import uk.ac.ukc.iscream.util.*; |
6 |
> |
import uk.org.iscream.util.*; |
7 |
|
|
8 |
|
/** |
9 |
|
* The class reads in data from a BufferedReader, |
32 |
|
* |
33 |
|
* @param inBound the BufferedReader this class should use |
34 |
|
* @param dataQueue the queue new data should be placed on |
35 |
+ |
* @param ch the connection handler in use |
36 |
|
*/ |
37 |
< |
public DataReader(BufferedReader inBound, Queue dataQueue) { |
37 |
> |
public DataReader(BufferedReader inBound, Queue dataQueue, ConnectionHandler ch) { |
38 |
> |
_ch = ch; |
39 |
|
_inBound = inBound; |
40 |
|
_dataQueue = dataQueue; |
41 |
|
} |
47 |
|
* It does this until either there is a problem |
48 |
|
* or it is told to stop. |
49 |
|
* |
50 |
+ |
* If there is a problem it calls shutdownLinks in the |
51 |
+ |
* ConnectionHandler. |
52 |
+ |
* |
53 |
|
* Any data it reads it converts to XML and then |
54 |
|
* adds to its queue. |
55 |
|
*/ |
70 |
|
_inBound.close(); |
71 |
|
|
72 |
|
} catch (IOException e) { |
73 |
< |
Conient.addMessage("Data Channel Shutdown: reason - "+e); |
73 |
> |
Conient.addMessage("WARNING{data reader}: inbound data stopped - "+e); |
74 |
|
_running = false; |
75 |
+ |
// tell the ConnectionHandler to shut down the links |
76 |
+ |
_ch.shutdownLinks(); |
77 |
|
} |
78 |
|
} |
79 |
|
|
94 |
|
/** |
95 |
|
* The reader we are reading from. |
96 |
|
*/ |
97 |
< |
BufferedReader _inBound; |
97 |
> |
private BufferedReader _inBound; |
98 |
|
|
99 |
|
/** |
100 |
|
* The Queue we place data on. |
101 |
|
*/ |
102 |
< |
Queue _dataQueue; |
102 |
> |
private Queue _dataQueue; |
103 |
|
|
104 |
|
/** |
105 |
|
* The state of this thread. |
106 |
|
*/ |
107 |
< |
boolean _running = true; |
107 |
> |
private boolean _running = true; |
108 |
> |
|
109 |
> |
/** |
110 |
> |
* A reference to the ConnectionHandler in use |
111 |
> |
*/ |
112 |
> |
private ConnectionHandler _ch; |
113 |
|
|
114 |
|
//---STATIC ATTRIBUTES--- |
115 |
|
|