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.14 by tdb, Tue May 29 17:02:34 2001 UTC

# Line 1 | Line 1
1   //---PACKAGE DECLARATION---
2 < package uk.ac.ukc.iscream.clientinterface;
2 > package uk.org.iscream.cms.server.clientinterface;
3  
4   //---IMPORTS---
5 < import uk.ac.ukc.iscream.util.*;
6 < import uk.ac.ukc.iscream.componentmanager.*;
7 < import uk.ac.ukc.iscream.core.*;
8 < import uk.ac.ukc.iscream.client.*;
5 > import uk.org.iscream.cms.server.util.*;
6 > import uk.org.iscream.cms.server.componentmanager.*;
7 > import uk.org.iscream.cms.server.core.*;
8 > import uk.org.iscream.cms.server.client.*;
9  
10  
11   /**
12   * Acts as a Control Handler to a CORBA based client.
13   *
14 * !!! FUNDAMENTAL DESIGN PROBLEM !!!
15 * !!! Need a way to "shutdown" this class !!!
16 *
14   * @author  $Author$
15   * @version $Id$
16   */
# Line 38 | Line 35 | class CorbaControlHandlerServant extends CorbaControlH
35       * @param queueMonitorInterval The interval at which to monitor our Queue.
36       * @param clientname A name to identify the client.
37       */
38 <    public CorbaControlHandlerServant(PacketSorter packetSorter, Client client, int queueMonitorInterval, String clientname) {
38 >    public CorbaControlHandlerServant(PacketSorter packetSorter, Client client, String clientname) {
39          _packetSorter = packetSorter;
43        _queueMonitorInterval = queueMonitorInterval;
40          _hostList = "";
41          _client = client;
42          _clientname = clientname;
# Line 58 | Line 54 | class CorbaControlHandlerServant extends CorbaControlH
54      public boolean startData() {
55          if(_dataHandler == null) {
56              // create a new DataHandler
57 <            CorbaDataHandler dh = new CorbaDataHandler(_client);
57 >            CorbaDataHandler dh = new CorbaDataHandler(_client, this);
58              // register the Queue
59              _packetSorter.register(dh.getQueue(), _hostList);
60 <            // startup a monitor on the DataHandler's queue, every minute
61 <            String queueName = _name + " CorbaHandler:"+_clientname;
62 <            dh.getQueue().startMonitor(_queueMonitorInterval*1000, _packetSorter.getQueue(), queueName);
60 >            try {
61 >                // startup a monitor on the DataHandler's queue
62 >                ConfigurationProxy cp = ConfigurationProxy.getInstance();
63 >                int queueMonitorInterval = Integer.parseInt(cp.getProperty("ClientInterface", "Queue.MonitorInterval"));
64 >                String queueName = _name + " CorbaHandler:"+_clientname;
65 >                dh.getQueue().startMonitor(queueMonitorInterval*1000, _packetSorter.getQueue(), queueName);
66 >            } catch (PropertyNotFoundException e) {
67 >                _logger.write(toString(), Logger.WARNING, "failed to find queue monitor config, disabling. " + e);
68 >            }
69              // start the DataHandler running
70              dh.start();
71              // keep a reference
# Line 113 | Line 115 | class CorbaControlHandlerServant extends CorbaControlH
115      }
116      
117      /**
118 +     * Disconnect, this will shutdown the data and unhook from
119 +     * the CORBA ORB.
120 +     */
121 +    public void disconnect() {
122 +        // close the data handler
123 +        stopData();
124 +        // disconnect from the ORB
125 +        try {
126 +            byte[] oid = _refman.getRootPOA().servant_to_id(this);
127 +            _refman.getRootPOA().deactivate_object(oid);
128 +        } catch(Exception e) {
129 +            _logger.write(this.toString(), Logger.ERROR, "disconnect failed: "+e);
130 +        }
131 +    }
132 +    
133 +    /**
134       * Overrides the {@link java.lang.Object#toString() Object.toString()}
135       * method to provide clean logging (every class should have this).
136       *
137 <     * This uses the uk.ac.ukc.iscream.util.NameFormat class
137 >     * This uses the uk.org.iscream.cms.server.util.NameFormat class
138       * to format the toString()
139       *
140       * @return the name of this class and its CVS revision
# Line 130 | Line 148 | class CorbaControlHandlerServant extends CorbaControlH
148  
149   //---PRIVATE METHODS---
150  
151 +    /**
152 +     * Overridden for debugging purposes
153 +     * to see when an instance of this class
154 +     * is destroyed
155 +     */
156 +    protected void finalize() throws Throwable {
157 +        _logger.write(this.toString(), Logger.DEBUG, "finalized by GC");
158 +    }
159 +
160   //---ACCESSOR/MUTATOR METHODS---
161  
162   //---ATTRIBUTES---
# Line 150 | Line 177 | class CorbaControlHandlerServant extends CorbaControlH
177       * system logger that is being used.
178       */
179      private Logger _logger = ReferenceManager.getInstance().getLogger();
180 +
181 +    /**
182 +     * A reference to the reference manager in use
183 +     */
184 +    private ReferenceManager _refman = ReferenceManager.getInstance();
185      
186      /**
187           * A reference to the PacketSorter.
# Line 170 | Line 202 | class CorbaControlHandlerServant extends CorbaControlH
202       * A reference to our DataHandler, if we have one
203       */
204      private CorbaDataHandler _dataHandler;
173    
174    /**
175     * The interval at which to monitor our Queue
176     */
177    private int _queueMonitorInterval;
205      
206      /**
207       * A name to identify the client

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines