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.3 by tdb, Wed Mar 14 23:25:29 2001 UTC vs.
Revision 1.7 by tdb, Tue May 29 17:02:34 2001 UTC

# Line 1 | Line 1
1   //---PACKAGE DECLARATION---
2 < package uk.org.iscream.client.monitors;
2 > package uk.org.iscream.cms.server.client.monitors;
3  
4   //---IMPORTS---
5 < import uk.org.iscream.client.*;
6 < import uk.org.iscream.core.*;
7 < import uk.org.iscream.util.*;
8 < import uk.org.iscream.componentmanager.*;
5 > import uk.org.iscream.cms.server.client.*;
6 > import uk.org.iscream.cms.server.core.*;
7 > import uk.org.iscream.cms.server.util.*;
8 > import uk.org.iscream.cms.server.componentmanager.*;
9  
10   /**
11   * Provides a full XMLPacket feed to the WebFeeder
# Line 13 | Line 13 | import uk.org.iscream.componentmanager.*;
13   * @author  $Author$
14   * @version $Id$
15   */
16 < public class WebFeeder__Monitor implements PluginMonitor {
16 > public class WebFeeder__Monitor extends Thread implements PluginMonitor {
17  
18   //---FINAL ATTRIBUTES---
19  
# Line 22 | Line 22 | public class WebFeeder__Monitor implements PluginMonit
22       */
23      public static final String REVISION = "$Revision$";
24      
25 +    /**
26 +     * A description of this monitor
27 +     */
28      public static final String DESC = "Provides a feed to WebFeeder";
29      
30   //---STATIC METHODS---
31  
32   //---CONSTRUCTORS---
33 <
33 >    
34 >    /**
35 >     * Constructs a new instance of this hook for the WebFeeder.
36 >     */
37      public WebFeeder__Monitor() {
38 <        _webFeeder = WebFeeder.getInstance();
38 >        this.start();
39      }
40  
41   //---PUBLIC METHODS---
42 <
42 >    
43 >    /**
44 >     * Keeps getting packets from the queue, and analyses
45 >     * them. In reality, this just sends them off to the
46 >     * WebFeeder for further processing.
47 >     */
48 >    public void run() {
49 >        while(_running) {
50 >            try {
51 >                analysePacket((XMLPacket) getQueue().get(getQueueId()));
52 >            } catch (InvalidQueueException e) {
53 >                _logger.write(this.toString(), Logger.ERROR, "Unable to get queue.");
54 >            }
55 >        }
56 >    }
57 >    
58 >    /**
59 >     * Sends a packet to the WebFeeder for processing, if
60 >     * we are active.
61 >     *
62 >     * @param packet the XMLPacket to send to the WebFeeder
63 >     */
64      public void analysePacket(XMLPacket packet) {
65          try {
66              ConfigurationProxy.getInstance().getProperty("WebFeeder", "WebFeeder.latestActive");
67 <            _webFeeder.receiveXMLPacket(packet);
67 >            WebFeeder.getInstance().receiveXMLPacket(packet);
68          } catch (PropertyNotFoundException e) {
69              // we don't care, this means we shouldn't be active
70          }
71      }
72 <
72 >    
73 >    /**
74 >     * return the String representation of what the monitor does
75 >     */
76      public String getDescription() {
77          return DESC;
78      }
# Line 51 | Line 81 | public class WebFeeder__Monitor implements PluginMonit
81       * Overrides the {@link java.lang.Object#toString() Object.toString()}
82       * method to provide clean logging (every class should have this).
83       *
84 <     * This uses the uk.org.iscream.util.FormatName class
84 >     * This uses the uk.org.iscream.cms.server.util.FormatName class
85       * to format the toString()
86       *
87       * @return the name of this class and its CVS revision
# Line 66 | Line 96 | public class WebFeeder__Monitor implements PluginMonit
96   //---PRIVATE METHODS---
97  
98   //---ACCESSOR/MUTATOR METHODS---
69
70 //---ATTRIBUTES---
99      
100 <    // reference to the WebFeeder
101 <    WebFeeder _webFeeder;
100 >    /**
101 >     * Returns a reference to a specific Queue for this
102 >     * monitor. This Queue returns only the data packets
103 >     * (based on type) that we want too look at.
104 >     *
105 >     * @return a reference to a Queue
106 >     */
107 >    protected Queue getQueue() {
108 >        return MonitorManager.getInstance().getAllQueue();
109 >    }
110      
111      /**
112 +     * Gets us a queue within the Queue we're using.
113 +     *
114 +     * @return a unique queue id number
115 +     */
116 +    protected int getQueueId() {
117 +        if (_qID == -1) {
118 +            _qID = getQueue().getQueue();
119 +        }
120 +        return _qID;
121 +    }
122 +    
123 + //---ATTRIBUTES---
124 +    
125 +    /**
126       * This is the friendly identifier of the
127       * component this class is running in.
128       * eg, a Filter may be called "filter1",
# Line 88 | Line 138 | public class WebFeeder__Monitor implements PluginMonit
138       * system logger that is being used.
139       */
140      private Logger _logger = ReferenceManager.getInstance().getLogger();
141 +    
142 +    /**
143 +     * Holds our queue ID number. Starts with -1, which
144 +     * indicates we don't have a queue.
145 +     */
146 +    protected int _qID = -1;
147 +    
148 +    /**
149 +     * A flag so we can stop if required.
150 +     */
151 +    protected boolean _running = true;
152  
153   //---STATIC ATTRIBUTES---
154  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines