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

Comparing projects/cms/source/server/uk/org/iscream/cms/server/rootfilter/CIWrapper.java (file contents):
Revision 1.5 by tdb, Fri Jan 19 01:12:14 2001 UTC vs.
Revision 1.12 by tdb, Sat May 18 18:16:02 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.ac.ukc.iscream.rootfilter;
21 > package uk.org.iscream.cms.server.rootfilter;
22  
23   //---IMPORTS---
24 < import uk.ac.ukc.iscream.core.*;
25 < import uk.ac.ukc.iscream.componentmanager.*;
26 < import uk.ac.ukc.iscream.clientinterface.*;
27 < import uk.ac.ukc.iscream.util.*;
24 > import uk.org.iscream.cms.server.core.*;
25 > import uk.org.iscream.cms.server.componentmanager.*;
26 > import uk.org.iscream.cms.server.clientinterface.*;
27 > import uk.org.iscream.cms.server.util.*;
28  
29   /**
30   * A ClientInterface wrapper - the CI objects are pushed data,
# Line 35 | Line 54 | public class CIWrapper extends Thread {
54       * @param queue a reference to a queue to use
55       */
56      public CIWrapper(ClientInterface destination, Queue queue){
57 +        // set the Thread name
58 +        setName("rootfilter.CIWrapper");
59 +        
60          _destination = destination;
61          _queue = queue;
62          _queueID = queue.getQueue();
# Line 47 | Line 69 | public class CIWrapper extends Thread {
69       */
70      public void run() {
71          String xml = null;
72 <        while(true) {
72 >        boolean run = true;
73 >        while(run) {
74 >            // get a line of XML from the queue
75              try {
76 <                xml = (String) _queue.get(n);
76 >                xml = (String) _queue.get(_queueID);
77              }
78              catch (InvalidQueueException e) {
79                  _logger.write(toString(), Logger.ERROR, "Queue error: "+e);
80              }
81 <            _destination.receiveXML(xml);
81 >            // pass it on to the destination
82 >            try {
83 >                _destination.receiveXML(xml);
84 >            }
85 >            catch (org.omg.CORBA.COMM_FAILURE e) {
86 >                run = false;
87 >                _logger.write(toString(), Logger.ERROR, "Connection failure (COMM_FAILURE), client interface shutdown? : "+e);
88 >            }
89 >            catch (org.omg.CORBA.TRANSIENT e) {
90 >                run = false;
91 >                _logger.write(toString(), Logger.ERROR, "Connection failure (TRANSIENT), client interface shutdown? : "+e);
92 >            }
93          }
94 +        // looks like something when wrong in communication
95 +        // rather than fall over in a heap, lets just stop
96 +        // cleanly and shutdown our queue...
97 +        _logger.write(toString(), Logger.SYSMSG, "Shutting Down...");
98 +        _queue.removeQueue(_queueID);
99      }
100  
101      /**
102       * Overrides the {@link java.lang.Object#toString() Object.toString()}
103       * method to provide clean logging (every class should have this).
104       *
105 +     * This uses the uk.org.iscream.cms.server.util.NameFormat class
106 +     * to format the toString()
107 +     *
108       * @return the name of this class and its CVS revision
109       */
110      public String toString() {
111 <        return this.getClass().getName() + "{" + _name + "}(" + REVISION.substring(11, REVISION.length() - 2) + ")";
111 >        return FormatName.getName(
112 >            _name,
113 >            getClass().getName(),
114 >            REVISION);
115      }
116  
117   //---PRIVATE METHODS---

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines