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.2 by tdb, Wed Nov 22 09:32:00 2000 UTC vs.
Revision 1.6 by tdb, Wed Nov 29 19:26:00 2000 UTC

# Line 1 | Line 1
1 + //---PACKAGE DECLARATION---
2 + package uk.ac.ukc.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  
11 < // This class contains the main method to be run by
12 < // the filter children.  It harvests UDP traffic.
13 < //
14 < //
11 > /**
12 > * This class contains the main method to be run by
13 > * the filter children.  It harvests UDP traffic.
14 > *
15 > * @author  $Author$
16 > * @version $Id$
17 > */
18   public class UDPReader extends Thread{
19  
20 + //---FINAL ATTRIBUTES---
21 +
22 +    /**
23 +     * The current CVS revision of this class
24 +     */
25 +    public final String REVISION = "$Revision$";
26 +    
27 + //---STATIC METHODS---
28 +
29 + //---CONSTRUCTORS---
30 +
31      // It is normal to use this constructor in preference
32      // to any other in this class.
33      public UDPReader(int port, Filter parent, Logger logger){
# Line 22 | Line 40 | public class UDPReader extends Thread{
40          this(4589, parent, logger);
41      }
42  
43 + //---PUBLIC METHODS---
44 +
45      public void run() {
46  
47          DatagramSocket socket = null;
# Line 29 | Line 49 | public class UDPReader extends Thread{
49              socket = new DatagramSocket(port);
50          }
51          catch (BindException e){
52 <            logger.write(this.toString(), Logger.SYSMSG, "Could not start the UDPReader thread on port "+port+" as this port was already in use.");
52 >            logger.write(this.toString(), Logger.FATAL, "Could not start the UDPReader thread on port "+port+" as this port was already in use.");
53              return;
54          }
55          catch (Exception e){
56 <            logger.write(this.toString(), Logger.SYSMSG, "Could not start the UDPReader thread on port "+port+".");
56 >            logger.write(this.toString(), Logger.FATAL, "Could not start the UDPReader thread on port "+port+".");
57              return;
58          }
59          
# Line 44 | Line 64 | public class UDPReader extends Thread{
64          boolean running = true;
65          while (running){
66              try {
67 +
68 +                    // receive request and pass on to the FilterThread.                
69                  buf = new byte[packetSizeLimit];
48                // receive request
70                  DatagramPacket packet = new DatagramPacket(buf, buf.length);
71                  socket.receive(packet);
72 <                FilterThread t = new FilterThread(parent);
73 <                t.run(packet);
72 >                FilterThread t = new FilterThread(packet, parent, logger);
73 >                t.start();
74 >
75              }
76              catch (IOException e) {
77 <                logger.write(this.toString(), Logger.SYSMSG, "The UDPReader thread has been shut down as an exception occured: "+e);
77 >                logger.write(this.toString(), Logger.WARNING, "This UDPReader thread has been shut down as an exception occured: "+e);
78                  return;
79              }
80          }
81          socket.close();
82      }
83 <    
84 <    
83 >
84 >    /**
85 >     * Overrides the {@link java.lang.Object#toString() Object.toString()}
86 >     * method to provide clean logging (every class should have this).
87 >     *
88 >     * @return the name of this class and its CVS revision
89 >     */
90 >    public String toString() {
91 >        return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")";
92 >    }
93 >
94 > //---PRIVATE METHODS---
95 >
96 > //---ACCESSOR/MUTATOR METHODS---
97 >
98 > //---ATTRIBUTES---
99 >
100      Logger logger;
101      int port;
102      Filter parent;    
103  
104      final int packetSizeLimit = 8192;
105 <    
105 >
106 > //---STATIC ATTRIBUTES---
107 >
108   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines