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

Comparing projects/cms/source/server/uk/org/iscream/cms/server/client/monitors/WebFeeder__Monitor.java (file contents):
Revision 1.2 by tdb, Thu Mar 8 23:20:10 2001 UTC vs.
Revision 1.9 by tdb, Tue May 21 16:47:16 2002 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * http://www.i-scream.org.uk
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.client.monitors;
22 > package uk.org.iscream.cms.server.client.monitors;
23  
24   //---IMPORTS---
25 < import uk.ac.ukc.iscream.client.*;
26 < import uk.ac.ukc.iscream.core.*;
27 < import uk.ac.ukc.iscream.util.*;
28 < import uk.ac.ukc.iscream.componentmanager.*;
25 > import uk.org.iscream.cms.server.client.*;
26 > import uk.org.iscream.cms.server.core.*;
27 > import uk.org.iscream.cms.server.util.*;
28 > import uk.org.iscream.cms.server.componentmanager.*;
29  
30   /**
31   * Provides a full XMLPacket feed to the WebFeeder
# Line 13 | Line 33 | import uk.ac.ukc.iscream.componentmanager.*;
33   * @author  $Author$
34   * @version $Id$
35   */
36 < public class WebFeeder__Monitor implements PluginMonitor {
36 > public class WebFeeder__Monitor extends Thread implements PluginMonitor {
37  
38   //---FINAL ATTRIBUTES---
39  
# Line 22 | Line 42 | public class WebFeeder__Monitor implements PluginMonit
42       */
43      public static final String REVISION = "$Revision$";
44      
45 +    /**
46 +     * A description of this monitor
47 +     */
48      public static final String DESC = "Provides a feed to WebFeeder";
49      
50   //---STATIC METHODS---
51  
52   //---CONSTRUCTORS---
53 <
53 >    
54 >    /**
55 >     * Constructs a new instance of this hook for the WebFeeder.
56 >     */
57      public WebFeeder__Monitor() {
58 <        _webFeeder = WebFeeder.getInstance();
58 >        this.start();
59      }
60  
61   //---PUBLIC METHODS---
62 <
62 >    
63 >    /**
64 >     * Keeps getting packets from the queue, and analyses
65 >     * them. In reality, this just sends them off to the
66 >     * WebFeeder for further processing.
67 >     */
68 >    public void run() {
69 >        while(_running) {
70 >            try {
71 >                analysePacket((XMLPacket) getQueue().get(getQueueId()));
72 >            } catch (InvalidQueueException e) {
73 >                _logger.write(this.toString(), Logger.ERROR, "Unable to get queue.");
74 >            }
75 >        }
76 >    }
77 >    
78 >    /**
79 >     * Sends a packet to the WebFeeder for processing, if
80 >     * we are active.
81 >     *
82 >     * @param packet the XMLPacket to send to the WebFeeder
83 >     */
84      public void analysePacket(XMLPacket packet) {
85          try {
86              ConfigurationProxy.getInstance().getProperty("WebFeeder", "WebFeeder.latestActive");
87 <            _webFeeder.receiveXMLPacket(packet);
87 >            WebFeeder.getInstance().receiveXMLPacket(packet);
88          } catch (PropertyNotFoundException e) {
89              // we don't care, this means we shouldn't be active
90          }
91      }
92 <
92 >    
93 >    /**
94 >     * return the String representation of what the monitor does
95 >     */
96      public String getDescription() {
97          return DESC;
98      }
# Line 51 | Line 101 | public class WebFeeder__Monitor implements PluginMonit
101       * Overrides the {@link java.lang.Object#toString() Object.toString()}
102       * method to provide clean logging (every class should have this).
103       *
104 <     * This uses the uk.ac.ukc.iscream.util.FormatName class
104 >     * This uses the uk.org.iscream.cms.server.util.FormatName class
105       * to format the toString()
106       *
107       * @return the name of this class and its CVS revision
# Line 66 | Line 116 | public class WebFeeder__Monitor implements PluginMonit
116   //---PRIVATE METHODS---
117  
118   //---ACCESSOR/MUTATOR METHODS---
69
70 //---ATTRIBUTES---
119      
120 <    // reference to the WebFeeder
121 <    WebFeeder _webFeeder;
120 >    /**
121 >     * Returns a reference to a specific Queue for this
122 >     * monitor. This Queue returns only the data packets
123 >     * (based on type) that we want too look at.
124 >     *
125 >     * @return a reference to a Queue
126 >     */
127 >    protected Queue getQueue() {
128 >        return MonitorManager.getInstance().getAllQueue();
129 >    }
130      
131      /**
132 +     * Gets us a queue within the Queue we're using.
133 +     *
134 +     * @return a unique queue id number
135 +     */
136 +    protected int getQueueId() {
137 +        if (_qID == -1) {
138 +            _qID = getQueue().getQueue();
139 +        }
140 +        return _qID;
141 +    }
142 +    
143 + //---ATTRIBUTES---
144 +    
145 +    /**
146       * This is the friendly identifier of the
147       * component this class is running in.
148       * eg, a Filter may be called "filter1",
# Line 88 | Line 158 | public class WebFeeder__Monitor implements PluginMonit
158       * system logger that is being used.
159       */
160      private Logger _logger = ReferenceManager.getInstance().getLogger();
161 +    
162 +    /**
163 +     * Holds our queue ID number. Starts with -1, which
164 +     * indicates we don't have a queue.
165 +     */
166 +    protected int _qID = -1;
167 +    
168 +    /**
169 +     * A flag so we can stop if required.
170 +     */
171 +    protected boolean _running = true;
172  
173   //---STATIC ATTRIBUTES---
174  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines