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

Comparing projects/cms/source/server/uk/org/iscream/cms/server/filter/UDPReader.java (file contents):
Revision 1.12 by tdb, Fri Jan 12 00:45:25 2001 UTC vs.
Revision 1.17 by tdb, Wed Mar 14 23:25:29 2001 UTC

# Line 1 | Line 1
1   //---PACKAGE DECLARATION---
2 < package uk.ac.ukc.iscream.filter;
2 > package uk.org.iscream.filter;
3  
4   //---IMPORTS---
5   import java.io.*;
6   import java.net.*;
7   import java.util.*;
8 < import uk.ac.ukc.iscream.core.*;
9 < import uk.ac.ukc.iscream.filter.*;
10 < import uk.ac.ukc.iscream.util.*;
8 > import uk.org.iscream.core.*;
9 > import uk.org.iscream.componentmanager.*;
10 > import uk.org.iscream.filter.*;
11 > import uk.org.iscream.util.*;
12  
13   /**
14   * This class contains the main method to be run by
15 < * the filter children.  It harvests UDP traffic.
15 > * the filterd.  It harvests UDP traffic, and queues it.
16   *
17   * @author  $Author$
18   * @version $Id$
# Line 24 | Line 25 | public class UDPReader extends Thread{
25       * The current CVS revision of this class
26       */
27      public final String REVISION = "$Revision$";
28 <
28 >    
29      /**
30       * The maximum size of a packet
31       */
# Line 35 | Line 36 | public class UDPReader extends Thread{
36   //---CONSTRUCTORS---
37  
38      /**
39 <     * It is normal to use this constructor in preference
40 <     * to any other in this class.
39 >     * Constructs a new UDPReader.
40 >     *
41 >     * @param port The port on which we listen for UDP data
42 >     * @param queue The queue which we are using
43       */
44      public UDPReader(int port, Queue queue){
45 +        // set the Thread name
46 +        setName("filter.UDPReader");
47 +        
48          _port = port;
49          _queue = queue;
50 +        _logger.write(toString(), Logger.SYSINIT, "started");
51      }
52  
53   //---PUBLIC METHODS---
54 <
54 >    
55 >    /**
56 >     * The main method in the class. Reads and queues XML sent
57 >     * over UDP.
58 >     */
59      public void run() {
60 <
60 >        
61 >        // setup a Datagram socket
62          DatagramSocket socket = null;
63          try {
64              socket = new DatagramSocket(_port);
# Line 61 | Line 73 | public class UDPReader extends Thread{
73          }
74          
75          _logger.write(this.toString(), Logger.SYSMSG, "UDPReader thread ready and listening for UDP packets on port "+_port);
76 <
76 >        
77          byte[] buf;
78          
79 +        // read UDP packets and queue them
80          boolean running = true;
81          while (running){
82              try {
83 <
84 <                    // receive request and put it in the Queue              
83 >                
84 >                // receive request and put it in the Queue              
85                  buf = new byte[packetSizeLimit];
86                  DatagramPacket packet = new DatagramPacket(buf, buf.length);
87                  socket.receive(packet);
# Line 77 | Line 90 | public class UDPReader extends Thread{
90              }
91              catch (IOException e) {
92                  _logger.write(this.toString(), Logger.WARNING, "This UDPReader thread has been shut down as an exception occured: "+e);
93 <                return;
93 >                running = false;
94              }
95          }
96          socket.close();
97      }
98 <
98 >    
99      /**
100       * Overrides the {@link java.lang.Object#toString() Object.toString()}
101       * method to provide clean logging (every class should have this).
102       *
103 <     * This uses the uk.ac.ukc.iscream.util.NameFormat class
103 >     * This uses the uk.org.iscream.util.NameFormat class
104       * to format the toString()
105       *
106       * @return the name of this class and its CVS revision
# Line 115 | Line 128 | public class UDPReader extends Thread{
128       * be changed to null for utility classes.
129       */
130      private String _name = FilterMain.NAME;
131 <
131 >    
132      /**
133       * This holds a reference to the
134       * system logger that is being used.
# Line 130 | Line 143 | public class UDPReader extends Thread{
143      /**
144       * The Queue object
145       */
146 <    Queue _queue;    
146 >    Queue _queue;
147  
148   //---STATIC ATTRIBUTES---
149  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines