21 |
|
* @author $Author$ |
22 |
|
* @version $Id$ |
23 |
|
*/ |
24 |
< |
public class IRC__Alerter implements PluginAlerter { |
24 |
> |
public class IRC__Alerter extends Thread implements PluginAlerter { |
25 |
|
|
26 |
|
//---FINAL ATTRIBUTES--- |
27 |
|
|
56 |
|
_ircbot.setName("client.IRC__Alerter$IRCBot"); |
57 |
|
_ircbot.start(); |
58 |
|
_startTime = System.currentTimeMillis(); |
59 |
< |
|
59 |
> |
this.start(); |
60 |
|
_logger.write(toString(), Logger.SYSINIT, "IRC Alerter started"); |
61 |
|
} |
62 |
|
|
63 |
|
//---PUBLIC METHODS--- |
64 |
|
|
65 |
+ |
public void run() { |
66 |
+ |
while(_running) { |
67 |
+ |
try { |
68 |
+ |
sendAlert((Alert) getQueue().get(getQueueId())); |
69 |
+ |
} catch (InvalidQueueException e) { |
70 |
+ |
_logger.write(this.toString(), Logger.ERROR, "Unable to get queue."); |
71 |
+ |
} |
72 |
+ |
} |
73 |
+ |
} |
74 |
+ |
|
75 |
|
public void sendAlert(Alert alert) { |
76 |
|
// only send alerts if we're active |
77 |
|
if(_active) { |
150 |
|
|
151 |
|
//---ACCESSOR/MUTATOR METHODS--- |
152 |
|
|
153 |
+ |
protected Queue getQueue() { |
154 |
+ |
return AlerterManager.getInstance().getQueue(); |
155 |
+ |
} |
156 |
+ |
|
157 |
+ |
protected int getQueueId() { |
158 |
+ |
if (_qID == -1) { |
159 |
+ |
_qID = getQueue().getQueue(); |
160 |
+ |
_logger.write(toString(), Logger.DEBUG, "Assigned Queue - " + _qID); |
161 |
+ |
} |
162 |
+ |
return _qID; |
163 |
+ |
} |
164 |
+ |
|
165 |
|
//---ATTRIBUTES--- |
166 |
|
|
167 |
|
/** |
200 |
|
private long _startTime; |
201 |
|
|
202 |
|
/** |
203 |
+ |
* The running status of the alerter |
204 |
+ |
*/ |
205 |
+ |
private boolean _running = true; |
206 |
+ |
|
207 |
+ |
/** |
208 |
|
* This is the friendly identifier of the |
209 |
|
* component this class is running in. |
210 |
|
* eg, a Filter may be called "filter1", |
220 |
|
* system logger that is being used. |
221 |
|
*/ |
222 |
|
private Logger _logger = ReferenceManager.getInstance().getLogger(); |
223 |
+ |
|
224 |
+ |
/** |
225 |
+ |
* The queue id for this alerters queue in the alert queue |
226 |
+ |
*/ |
227 |
+ |
private int _qID = -1; |
228 |
|
|
229 |
|
//---STATIC ATTRIBUTES--- |
230 |
|
|