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.21 by tdb, Wed Mar 20 13:05:50 2002 UTC vs.
Revision 1.28 by tdb, Wed Jan 14 15:23:25 2009 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * http://www.i-scream.org
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.org.iscream.cms.server.filter;
23  
24   //---IMPORTS---
25   import java.io.*;
26   import java.net.*;
7 import java.util.*;
27   import uk.org.iscream.cms.server.core.*;
28   import uk.org.iscream.cms.server.componentmanager.*;
29   import uk.org.iscream.cms.server.filter.*;
30 < import uk.org.iscream.cms.server.util.*;
30 > import uk.org.iscream.cms.util.*;
31  
32   /**
33   * This class contains the main method to be run by
# Line 29 | Line 48 | public class UDPReader extends Thread{
48      /**
49       * The maximum size of a packet
50       */
51 <    private final int packetSizeLimit = 8192;  
51 >    private final int packetSizeLimit = 32768;
52      
53   //---STATIC METHODS---
54  
# Line 57 | Line 76 | public class UDPReader extends Thread{
76       * over UDP.
77       */
78      public void run() {
79 <        // get our ACL from the configuration
80 <        ACL acl = null;
62 <        try {
63 <            String stringACL = ConfigurationProxy.getInstance().getProperty("Filter." + FilterMain.NAME, "Filter.UDPACL");
64 <            acl = new ACL(stringACL);
65 <        }
66 <        catch(PropertyNotFoundException e) {
67 <            _logger.write(toString(), Logger.WARNING, "No ACL found for UDPReader: " + e);
68 <        }
79 >        // setup an empty ACL defaulting to ALLOW
80 >        ACL acl = new ACL(ACL.ALLOW);
81          
82          // setup a Datagram socket
83          DatagramSocket socket = null;
84          try {
85 <            // use an ACLServerSocket if we have an ACL
74 <                        if(acl != null) {
75 <                            socket = new ACLDatagramSocket(acl, _port);
76 <                        }
77 <                        else {
78 <                socket = new DatagramSocket(_port);
79 <            }
85 >            socket = new ACLDatagramSocket(acl, _port);
86          }
87          catch (BindException e){
88              _logger.write(this.toString(), Logger.FATAL, "Could not start the UDPReader thread on port "+_port+" as this port was already in use.");
# Line 91 | Line 97 | public class UDPReader extends Thread{
97          
98          byte[] buf;
99          
100 +        ConfigurationProxy cp = ConfigurationProxy.getInstance();
101 +        String stringACL = "";
102 +        String newStringACL = "";
103 +        
104          // read UDP packets and queue them
105          boolean running = true;
106          while (running){
107 +            // get hold of the ACL in the configuration
108              try {
109 +                newStringACL = cp.getProperty("Filter." + FilterMain.NAME, "Filter.UDPACL");
110 +            }
111 +            catch(PropertyNotFoundException e) {
112 +                // if we can't find it, we'll just use a null ACL
113 +                newStringACL = "";
114 +                _logger.write(toString(), Logger.WARNING, "No ACL found for UDPReader, using empty ACL instead: " + e);
115 +            }
116 +            // check to see if the ACL has changed
117 +            if(!newStringACL.equals(stringACL)) {
118 +                _logger.write(toString(), Logger.SYSMSG, "Reloading Access Control List");
119 +                // clear the ACL
120 +                acl.clear();
121 +                // set the default to something sane
122 +                acl.setDefaultMode(ACL.ALLOW);
123 +                // add the new ACL (this may change the default)
124 +                acl.add(newStringACL);
125 +                stringACL = newStringACL;
126 +            }
127 +            try {
128                  
129                  // receive request and put it in the Queue              
130                  buf = new byte[packetSizeLimit];
# Line 115 | Line 145 | public class UDPReader extends Thread{
145       * Overrides the {@link java.lang.Object#toString() Object.toString()}
146       * method to provide clean logging (every class should have this).
147       *
148 <     * This uses the uk.org.iscream.cms.server.util.NameFormat class
148 >     * This uses the uk.org.iscream.cms.util.NameFormat class
149       * to format the toString()
150       *
151       * @return the name of this class and its CVS revision

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines