ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/conient/uk/org/iscream/cms/conient/DataReader.java
(Generate patch)

Comparing projects/cms/source/conient/uk/org/iscream/cms/conient/DataReader.java (file contents):
Revision 1.8 by ajm, Wed Jan 24 03:21:25 2001 UTC vs.
Revision 1.13 by ajm, Fri Mar 23 04:05:26 2001 UTC

# Line 1 | Line 1
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,
# Line 32 | Line 32 | public class DataReader extends Thread {
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      }
# Line 45 | Line 47 | public class DataReader extends Thread {
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       */
# Line 55 | Line 60 | public class DataReader extends Thread {
60              // continue until we are told to stop
61              while (_running) {
62                  line = _inBound.readLine();
63 +                if (line == null) {
64 +                    throw new IOException("unexpected loss of connection to server");
65 +                }
66                  _dataQueue.add(line);
67              }
68          
# Line 62 | Line 70 | public class DataReader extends Thread {
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.shutdownDataLink();
77          }
78      }
79  
# Line 84 | Line 94 | public class DataReader extends Thread {
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  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines