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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines