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.9 by ajm, Thu Nov 30 02:38:09 2000 UTC vs.
Revision 1.13 by tdb, Thu Jan 18 23:16:21 2001 UTC

# Line 6 | Line 6 | import java.io.*;
6   import java.net.*;
7   import java.util.*;
8   import uk.ac.ukc.iscream.core.*;
9 + import uk.ac.ukc.iscream.componentmanager.*;
10   import uk.ac.ukc.iscream.filter.*;
11   import uk.ac.ukc.iscream.util.*;
12  
# 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 +
29 +    /**
30 +     * The maximum size of a packet
31 +     */
32 +    private final int packetSizeLimit = 8192;  
33      
34   //---STATIC METHODS---
35  
36   //---CONSTRUCTORS---
37  
38 <    // It is normal to use this constructor in preference
39 <    // to any other in this class.
40 <    public UDPReader(int port, Filter parent){
38 >    /**
39 >     * It is normal to use this constructor in preference
40 >     * to any other in this class.
41 >     */
42 >    public UDPReader(int port, Queue queue){
43          _port = port;
44 <        _parent = parent;
44 >        _queue = queue;
45      }
46  
47   //---PUBLIC METHODS---
# Line 61 | Line 69 | public class UDPReader extends Thread{
69          while (running){
70              try {
71  
72 <                    // receive request and pass on to the FilterThread.                
72 >                    // receive request and put it in the Queue              
73                  buf = new byte[packetSizeLimit];
74                  DatagramPacket packet = new DatagramPacket(buf, buf.length);
75                  socket.receive(packet);
76 <                FilterThread t = new FilterThread(packet, _parent);
77 <                t.start();
70 <
76 >                String xml = new String(packet.getData());
77 >                _queue.add(xml);
78              }
79              catch (IOException e) {
80                  _logger.write(this.toString(), Logger.WARNING, "This UDPReader thread has been shut down as an exception occured: "+e);
# Line 81 | Line 88 | public class UDPReader extends Thread{
88       * Overrides the {@link java.lang.Object#toString() Object.toString()}
89       * method to provide clean logging (every class should have this).
90       *
91 +     * This uses the uk.ac.ukc.iscream.util.NameFormat class
92 +     * to format the toString()
93 +     *
94       * @return the name of this class and its CVS revision
95       */
96      public String toString() {
97 <        return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")";
97 >        return FormatName.getName(
98 >            _name,
99 >            getClass().getName(),
100 >            REVISION);
101      }
102  
103   //---PRIVATE METHODS---
# Line 93 | Line 106 | public class UDPReader extends Thread{
106  
107   //---ATTRIBUTES---
108  
109 <    Logger _logger = ReferenceManager.getInstance().getLogger();
110 <    int _port;
111 <    Filter _parent;    
109 >    /**
110 >     * This is the friendly identifier of the
111 >     * component this class is running in.
112 >     * eg, a Filter may be called "filter1",
113 >     * If this class does not have an owning
114 >     * component,  a name from the configuration
115 >     * can be placed here.  This name could also
116 >     * be changed to null for utility classes.
117 >     */
118 >    private String _name = FilterMain.NAME;
119  
120 <    final int packetSizeLimit = 8192;
120 >    /**
121 >     * This holds a reference to the
122 >     * system logger that is being used.
123 >     */
124 >    private Logger _logger = ReferenceManager.getInstance().getLogger();
125 >    
126 >    /**
127 >     * The port that this reader is using
128 >     */
129 >    int _port;
130 >    
131 >    /**
132 >     * The Queue object
133 >     */
134 >    Queue _queue;    
135  
136   //---STATIC ATTRIBUTES---
137  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines