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

Comparing projects/cms/source/server/uk/org/iscream/cms/server/clientinterface/CorbaDataHandler.java (file contents):
Revision 1.6 by tdb, Wed Mar 14 23:25:29 2001 UTC vs.
Revision 1.12 by tdb, Sat May 18 18:16:01 2002 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * Copyright (C) 2000-2002 i-scream
4 + *
5 + * This program is free software; you can redistribute it and/or
6 + * modify it under the terms of the GNU General Public License
7 + * as published by the Free Software Foundation; either version 2
8 + * of the License, or (at your option) any later version.
9 + *
10 + * This program is distributed in the hope that it will be useful,
11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 + * GNU General Public License for more details.
14 + *
15 + * You should have received a copy of the GNU General Public License
16 + * along with this program; if not, write to the Free Software
17 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 + */
19 +
20   //---PACKAGE DECLARATION---
21 < package uk.org.iscream.clientinterface;
21 > package uk.org.iscream.cms.server.clientinterface;
22  
23   //---IMPORTS---
24 < import uk.org.iscream.util.*;
25 < import uk.org.iscream.componentmanager.*;
26 < import uk.org.iscream.core.*;
27 < import uk.org.iscream.client.*;
24 > import uk.org.iscream.cms.server.util.*;
25 > import uk.org.iscream.cms.server.componentmanager.*;
26 > import uk.org.iscream.cms.server.core.*;
27 > import uk.org.iscream.cms.server.client.*;
28  
29  
30   /**
# Line 31 | Line 50 | class CorbaDataHandler extends Thread {
50       * Construct a new CorbaDataHandler.
51       *
52       * @param client A reference to the "servant" part of the connecting client.
53 +     * @param cchServer A reference to the class that is control us.
54       */
55 <    public CorbaDataHandler(Client client) {
55 >    public CorbaDataHandler(Client client, CorbaControlHandlerServant cchServant) {
56          // set the Thread name
57          setName("clientinterface.CorbaDataHandler");
58          
59 <        _queue = new Queue();
59 >        ConfigurationProxy cp = ConfigurationProxy.getInstance();
60 >        String configName = "ClientInterface";
61 >        // see if this Queue needs a size limit
62 >        try {
63 >            int queueSizeLimit = Integer.parseInt(cp.getProperty(configName, "Queue.SizeLimit"));
64 >            String queueRemoveAlgorithm = cp.getProperty(configName, "Queue.RemoveAlgorithm");
65 >            int algorithm = StringUtils.getStringPos(queueRemoveAlgorithm, Queue.algorithms);
66 >            if(algorithm != -1) {
67 >                _logger.write(toString(), Logger.DEBUG, "Starting Queue with size limit of "+queueSizeLimit+", using remove algorithm "+queueRemoveAlgorithm);
68 >                // we have valid values, so lets start it.
69 >                _queue = new Queue(queueSizeLimit, algorithm);
70 >            }
71 >            else {
72 >                _logger.write(toString(), Logger.WARNING, "Bad Queue Algorithm configuration, not known: "+queueRemoveAlgorithm);
73 >                // just don't activate a limit
74 >                _queue = new Queue();
75 >            }
76 >            
77 >        } catch (PropertyNotFoundException e) {
78 >            _logger.write(toString(), Logger.DEBUG, "Optional config not set: "+e);
79 >            // just don't activate a limit
80 >            _queue = new Queue();
81 >        } catch (NumberFormatException e) {
82 >            _logger.write(toString(), Logger.WARNING, "Bad Queue SizeLimit configuration: "+e);
83 >            // just don't activate a limit
84 >            _queue = new Queue();
85 >        }
86 >
87          _client = client;
88 +        _cchServant = cchServant;
89          _logger.write(toString(), Logger.SYSINIT, "created");
90      }
91      
# Line 66 | Line 114 | class CorbaDataHandler extends Thread {
114                      catch (org.omg.CORBA.COMM_FAILURE e) {
115                          // lets stop sending, the client has quit
116                          run = false;
117 <                        _logger.write(toString(), Logger.ERROR, "Connection failure, client shutdown? : "+e);
117 >                        _logger.write(toString(), Logger.ERROR, "Connection failure (COMM_FAILURE), client shutdown? : "+e);
118                      }
119 +                    catch (org.omg.CORBA.TRANSIENT e) {
120 +                        // lets stop sending, the client has quit
121 +                        run = false;
122 +                        _logger.write(toString(), Logger.ERROR, "Connection failure (TRANSIENT), client shutdown? : "+e);
123 +                    }
124                  }
125              }
126              catch(InvalidQueueException e) {
# Line 76 | Line 129 | class CorbaDataHandler extends Thread {
129                  _logger.write(toString(), Logger.ERROR, "Queue failure: "+e);
130              }
131          }
132 +        // disconnect the servant above us, or at least try
133 +        _cchServant.disconnect();
134          // if we get here we've been told to stop
135          _logger.write(toString(), Logger.SYSMSG, "Shutting Down");
136          // remove ourselves from the queue
# Line 100 | Line 155 | class CorbaDataHandler extends Thread {
155       * Overrides the {@link java.lang.Object#toString() Object.toString()}
156       * method to provide clean logging (every class should have this).
157       *
158 <     * This uses the uk.org.iscream.util.NameFormat class
158 >     * This uses the uk.org.iscream.cms.server.util.NameFormat class
159       * to format the toString()
160       *
161       * @return the name of this class and its CVS revision
# Line 114 | Line 169 | class CorbaDataHandler extends Thread {
169  
170   //---PRIVATE METHODS---
171  
172 +    /**
173 +     * Overridden for debugging purposes
174 +     * to see when an instance of this class
175 +     * is destroyed
176 +     */
177 +    protected void finalize() throws Throwable {
178 +        _logger.write(this.toString(), Logger.DEBUG, "finalized by GC");
179 +    }
180 +
181   //---ACCESSOR/MUTATOR METHODS---
182  
183      /**
# Line 164 | Line 228 | class CorbaDataHandler extends Thread {
228       * The flag that dictates whether the main loop should *completely* exit
229       */
230      private boolean run;
231 +    
232 +    /**
233 +     * A reference to our controlling class
234 +     */
235 +    private CorbaControlHandlerServant _cchServant;
236      
237   //---STATIC ATTRIBUTES---
238  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines