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.org.iscream.client.monitors; |
22 |
> |
package uk.org.iscream.cms.server.client.monitors; |
23 |
|
|
24 |
|
//---IMPORTS--- |
25 |
< |
import uk.org.iscream.client.*; |
26 |
< |
import uk.org.iscream.core.*; |
27 |
< |
import uk.org.iscream.util.*; |
28 |
< |
import uk.org.iscream.componentmanager.*; |
25 |
> |
import uk.org.iscream.cms.server.client.*; |
26 |
> |
import uk.org.iscream.cms.server.core.*; |
27 |
> |
import uk.org.iscream.cms.util.*; |
28 |
> |
import uk.org.iscream.cms.server.componentmanager.*; |
29 |
|
|
30 |
|
/** |
31 |
|
* Provides a full XMLPacket feed to the WebFeeder |
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() { |
32 |
– |
_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 |
< |
try { |
70 |
< |
analysePacket((XMLPacket) getQueue().get(getQueueId())); |
71 |
< |
} catch (InvalidQueueException e) { |
72 |
< |
_logger.write(this.toString(), Logger.ERROR, "Unable to get queue."); |
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 |
< |
|
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 |
|
} |
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.org.iscream.util.FormatName class |
104 |
> |
* This uses the uk.org.iscream.cms.util.FormatName class |
105 |
|
* to format the toString() |
106 |
|
* |
107 |
|
* @return the name of this class and its CVS revision |
116 |
|
//---PRIVATE METHODS--- |
117 |
|
|
118 |
|
//---ACCESSOR/MUTATOR METHODS--- |
119 |
< |
|
119 |
> |
|
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 |
< |
|
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 |
< |
|
142 |
> |
|
143 |
|
//---ATTRIBUTES--- |
144 |
|
|
92 |
– |
// reference to the WebFeeder |
93 |
– |
WebFeeder _webFeeder; |
94 |
– |
|
145 |
|
/** |
146 |
|
* This is the friendly identifier of the |
147 |
|
* component this class is running in. |
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 |
|
|