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.20 by tdb, Wed Mar 20 12:56:37 2002 UTC vs.
Revision 1.26 by tdb, Sun Aug 1 10:40:59 2004 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  
# Line 8 | Line 28 | import java.util.*;
28   import uk.org.iscream.cms.server.core.*;
29   import uk.org.iscream.cms.server.componentmanager.*;
30   import uk.org.iscream.cms.server.filter.*;
31 < import uk.org.iscream.cms.server.util.*;
31 > import uk.org.iscream.cms.util.*;
32  
33   /**
34   * This class contains the main method to be run by
# Line 57 | Line 77 | public class UDPReader extends Thread{
77       * over UDP.
78       */
79      public void run() {
80 <        // get our ACL from the configuration
81 <        ACL acl = null;
62 <        try {
63 <            String stringACL = ConfigurationProxy.getInstance().getProperty(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 <        }
80 >        // setup an empty ACL defaulting to ALLOW
81 >        ACL acl = new ACL(ACL.ALLOW);
82          
83          // setup a Datagram socket
84          DatagramSocket socket = null;
85          try {
86 <            // 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 <            }
86 >            socket = new ACLDatagramSocket(acl, _port);
87          }
88          catch (BindException e){
89              _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 98 | public class UDPReader extends Thread{
98          
99          byte[] buf;
100          
101 +        ConfigurationProxy cp = ConfigurationProxy.getInstance();
102 +        String stringACL = "";
103 +        String newStringACL = "";
104 +        
105          // read UDP packets and queue them
106          boolean running = true;
107          while (running){
108 +            // get hold of the ACL in the configuration
109              try {
110 +                newStringACL = cp.getProperty("Filter." + FilterMain.NAME, "Filter.UDPACL");
111 +            }
112 +            catch(PropertyNotFoundException e) {
113 +                // if we can't find it, we'll just use a null ACL
114 +                newStringACL = "";
115 +                _logger.write(toString(), Logger.WARNING, "No ACL found for UDPReader, using empty ACL instead: " + e);
116 +            }
117 +            // check to see if the ACL has changed
118 +            if(!newStringACL.equals(stringACL)) {
119 +                _logger.write(toString(), Logger.SYSMSG, "Reloading Access Control List");
120 +                // clear the ACL
121 +                acl.clear();
122 +                // set the default to something sane
123 +                acl.setDefaultMode(ACL.ALLOW);
124 +                // add the new ACL (this may change the default)
125 +                acl.add(newStringACL);
126 +                stringACL = newStringACL;
127 +            }
128 +            try {
129                  
130                  // receive request and put it in the Queue              
131                  buf = new byte[packetSizeLimit];
# Line 115 | Line 146 | public class UDPReader extends Thread{
146       * Overrides the {@link java.lang.Object#toString() Object.toString()}
147       * method to provide clean logging (every class should have this).
148       *
149 <     * This uses the uk.org.iscream.cms.server.util.NameFormat class
149 >     * This uses the uk.org.iscream.cms.util.NameFormat class
150       * to format the toString()
151       *
152       * @return the name of this class and its CVS revision

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines