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/CorbaControlHandlerServant.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/clientinterface/CorbaControlHandlerServant.java (file contents):
Revision 1.6 by tdb, Wed Feb 28 19:04:00 2001 UTC vs.
Revision 1.19 by tdb, Sun Aug 1 10:40:48 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.ac.ukc.iscream.clientinterface;
22 > package uk.org.iscream.cms.server.clientinterface;
23  
24   //---IMPORTS---
25 < import uk.ac.ukc.iscream.util.*;
26 < import uk.ac.ukc.iscream.componentmanager.*;
27 < import uk.ac.ukc.iscream.core.*;
8 < import uk.ac.ukc.iscream.client.*;
25 > import uk.org.iscream.cms.util.*;
26 > import uk.org.iscream.cms.server.componentmanager.*;
27 > import uk.org.iscream.cms.server.core.*;
28  
29  
30   /**
31   * Acts as a Control Handler to a CORBA based client.
32   *
14 * !!! FUNDAMENTAL DESIGN PROBLEM !!!
15 * !!! Need a way to "shutdown" this class !!!
16 *
33   * @author  $Author$
34   * @version $Id$
35   */
# Line 35 | Line 51 | class CorbaControlHandlerServant extends CorbaControlH
51       *
52       * @param packetSorter A reference to the PacketSorter in the component
53       * @param client A reference to the "servant" part of the connecting client.
38     * @param queueMonitorInterval The interval at which to monitor our Queue.
54       * @param clientname A name to identify the client.
55       */
56 <    public CorbaControlHandlerServant(PacketSorter packetSorter, Client client, int queueMonitorInterval, String clientname) {
56 >    public CorbaControlHandlerServant(PacketSorter packetSorter, Client client, String clientname) {
57          _packetSorter = packetSorter;
43        _queueMonitorInterval = queueMonitorInterval;
58          _hostList = "";
59          _client = client;
60          _clientname = clientname;
# Line 58 | Line 72 | class CorbaControlHandlerServant extends CorbaControlH
72      public boolean startData() {
73          if(_dataHandler == null) {
74              // create a new DataHandler
75 <            CorbaDataHandler dh = new CorbaDataHandler(_client);
75 >            CorbaDataHandler dh = new CorbaDataHandler(_client, this);
76              // register the Queue
77              _packetSorter.register(dh.getQueue(), _hostList);
78 <            // startup a monitor on the DataHandler's queue, every minute
79 <            String queueName = _name + " CorbaHandler:"+_clientname;
80 <            dh.getQueue().startMonitor(_queueMonitorInterval*1000, _packetSorter.getQueue(), queueName);
78 >            try {
79 >                // startup a monitor on the DataHandler's queue
80 >                ConfigurationProxy cp = ConfigurationProxy.getInstance();
81 >                int queueMonitorInterval = Integer.parseInt(cp.getProperty("ClientInterface", "Queue.MonitorInterval"));
82 >                String queueName = _name + " CorbaHandler:"+_clientname;
83 >                dh.getQueue().startMonitor(queueMonitorInterval*1000, _packetSorter.getQueue(), queueName);
84 >            } catch (PropertyNotFoundException e) {
85 >                _logger.write(toString(), Logger.WARNING, "failed to find queue monitor config, disabling. " + e);
86 >            }
87              // start the DataHandler running
88              dh.start();
89              // keep a reference
# Line 113 | Line 133 | class CorbaControlHandlerServant extends CorbaControlH
133      }
134      
135      /**
136 +     * Disconnect, this will shutdown the data and unhook from
137 +     * the CORBA ORB.
138 +     */
139 +    public void disconnect() {
140 +        // close the data handler
141 +        stopData();
142 +        // disconnect from the ORB
143 +        try {
144 +            byte[] oid = _refman.getRootPOA().servant_to_id(this);
145 +            _refman.getRootPOA().deactivate_object(oid);
146 +        } catch(Exception e) {
147 +            _logger.write(this.toString(), Logger.ERROR, "disconnect failed: "+e);
148 +        }
149 +    }
150 +    
151 +    /**
152       * Overrides the {@link java.lang.Object#toString() Object.toString()}
153       * method to provide clean logging (every class should have this).
154       *
155 <     * This uses the uk.ac.ukc.iscream.util.NameFormat class
155 >     * This uses the uk.org.iscream.cms.util.NameFormat class
156       * to format the toString()
157       *
158       * @return the name of this class and its CVS revision
# Line 130 | Line 166 | class CorbaControlHandlerServant extends CorbaControlH
166  
167   //---PRIVATE METHODS---
168  
169 +    /**
170 +     * Overridden for debugging purposes
171 +     * to see when an instance of this class
172 +     * is destroyed
173 +     */
174 +    protected void finalize() throws Throwable {
175 +        _logger.write(this.toString(), Logger.DEBUG, "finalized by GC");
176 +    }
177 +
178   //---ACCESSOR/MUTATOR METHODS---
179  
180   //---ATTRIBUTES---
# Line 150 | Line 195 | class CorbaControlHandlerServant extends CorbaControlH
195       * system logger that is being used.
196       */
197      private Logger _logger = ReferenceManager.getInstance().getLogger();
198 +
199 +    /**
200 +     * A reference to the reference manager in use
201 +     */
202 +    private ReferenceManager _refman = ReferenceManager.getInstance();
203      
204      /**
205           * A reference to the PacketSorter.
# Line 170 | Line 220 | class CorbaControlHandlerServant extends CorbaControlH
220       * A reference to our DataHandler, if we have one
221       */
222      private CorbaDataHandler _dataHandler;
173    
174    /**
175     * The interval at which to monitor our Queue
176     */
177    private int _queueMonitorInterval;
223      
224      /**
225       * A name to identify the client

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines