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.7 by ajm, Wed Jan 24 03:09:45 2001 UTC vs.
Revision 1.16 by tdb, Tue May 21 16:47:10 2002 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * http://www.i-scream.org.uk
4 + * Copyright (C) 2000-2002 i-scream
5 + *
6 + * This program is free software; you can redistribute it and/or
7 + * modify it under the terms of the GNU General Public License
8 + * as published by the Free Software Foundation; either version 2
9 + * of the License, or (at your option) any later version.
10 + *
11 + * This program is distributed in the hope that it will be useful,
12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 + * GNU General Public License for more details.
15 + *
16 + * You should have received a copy of the GNU General Public License
17 + * along with this program; if not, write to the Free Software
18 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 + */
20 +
21   //---PACKAGE DECLARATION---
22 < package uk.ac.ukc.iscream.conient;
22 > package uk.org.iscream.cms.conient;
23  
24   //---IMPORTS---
25   import java.io.*;
26 < import uk.ac.ukc.iscream.util.*;
26 > import uk.org.iscream.cms.server.util.*;
27  
28   /**
29   * The class reads in data from a BufferedReader,
# Line 32 | Line 52 | public class DataReader extends Thread {
52       *
53       * @param inBound the BufferedReader this class should use
54       * @param dataQueue the queue new data should be placed on
55 +     * @param ch the connection handler in use
56       */
57 <    public DataReader(BufferedReader inBound, Queue dataQueue) {
57 >    public DataReader(BufferedReader inBound, Queue dataQueue, ConnectionHandler ch) {
58 >        _ch = ch;
59          _inBound = inBound;
60          _dataQueue = dataQueue;
61      }
# Line 45 | Line 67 | public class DataReader extends Thread {
67       * It does this until either there is a problem
68       * or it is told to stop.
69       *
70 +     * If there is a problem it calls shutdownLinks in the
71 +     * ConnectionHandler.
72 +     *
73       * Any data it reads it converts to XML and then
74       * adds to its queue.
75       */
# Line 55 | Line 80 | public class DataReader extends Thread {
80              // continue until we are told to stop
81              while (_running) {
82                  line = _inBound.readLine();
83 +                if (line == null) {
84 +                    throw new IOException("unexpected loss of connection to server");
85 +                }
86                  _dataQueue.add(line);
87              }
88          
# Line 62 | Line 90 | public class DataReader extends Thread {
90              _inBound.close();
91          
92          } catch (IOException e) {
93 <            SwingClient.addMessage("Data Channel Shutdown: reason - "+e);
93 >            Conient.addMessage("WARNING{data reader}: inbound data stopped - "+e);
94              _running = false;
95 +            // tell the ConnectionHandler to shut down the links
96 +            _ch.shutdownDataLink();
97          }
98      }
99  
# Line 84 | Line 114 | public class DataReader extends Thread {
114      /**
115       * The reader we are reading from.
116       */
117 <    BufferedReader _inBound;
117 >    private BufferedReader _inBound;
118      
119      /**
120       * The Queue we place data on.
121       */
122 <    Queue _dataQueue;
122 >    private Queue _dataQueue;
123      
124      /**
125       * The state of this thread.
126       */
127 <    boolean _running = true;
127 >    private boolean _running = true;
128 >    
129 >    /**
130 >     * A reference to the ConnectionHandler in use
131 >     */
132 >    private ConnectionHandler _ch;
133      
134   //---STATIC ATTRIBUTES---
135  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines