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 |
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() { |
32 |
– |
_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 |
< |
try { |
50 |
< |
analysePacket((XMLPacket) getQueue().get(getQueueId())); |
51 |
< |
} catch (InvalidQueueException e) { |
52 |
< |
_logger.write(this.toString(), Logger.ERROR, "Unable to get queue."); |
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 |
< |
|
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 |
|
} |
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 |
96 |
|
//---PRIVATE METHODS--- |
97 |
|
|
98 |
|
//---ACCESSOR/MUTATOR METHODS--- |
99 |
< |
|
99 |
> |
|
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 |
< |
|
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 |
< |
|
122 |
> |
|
123 |
|
//---ATTRIBUTES--- |
124 |
|
|
92 |
– |
// reference to the WebFeeder |
93 |
– |
WebFeeder _webFeeder; |
94 |
– |
|
125 |
|
/** |
126 |
|
* This is the friendly identifier of the |
127 |
|
* component this class is running in. |
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 |
|
|