|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.solab.alarms.AbstractAlarmChannel
com.solab.alarms.channels.twitter.TwitterChannel
public class TwitterChannel
A channel that uses Twitter to publish alarms. The way this works is like this: You set up a Twitter account for your application, and follow it from your own account. You must run the TwitterAuth class in this app to generate a Token associating the jAlarms app with the account you'll use for the app (you only need to do this once). Then you set the PIN you get in the twitterPin property of this component and you're ready to go; any alarms published here will be posted as the status of the account you set up for the app, and since you're following it, you'll know when something bad happens. Twitter ignores repeated status updates, which is kinda necessary here... so this channel prepends the time to the alarm messages, which solves the problem for at least a day (but it seems like Twitter allows repeated status updates after a day, so it's OK). The time is displayed as HHmmss, using no separators to save space. Alarm messages longer than 133 chars will be split into several status messages. Since this channel only updates the status of a Twitter account, alarm sources are ignored.
Field Summary |
---|
Fields inherited from class com.solab.alarms.AbstractAlarmChannel |
---|
log |
Constructor Summary | |
---|---|
TwitterChannel()
|
Method Summary | |
---|---|
protected Runnable |
createSendTask(String msg,
String src)
Subclasses need to create and return a new Runnable in each call to this method. |
String |
getApiUrl()
|
protected boolean |
hasSource(String alarmSource)
This method is used to determine if a certain alarm channel has a special condition for the specified alarmSource or not. |
void |
init()
Initializes the component. |
void |
setAccessToken(String value)
Sets the access token obtained with the TwitterAuth program; this allows jAlarms to post status updates to the twitter account set up for the alarms. |
void |
setAlarmSource(Set<String> value)
You can set a list of sources in this property so that only alarm messages matching any of the sources are be posted as status updates. |
void |
setApiUrl(String value)
Sets the Twitter API URL to update the user's status. |
void |
setPrefix(String value)
This is an optional property; you can set a prefix to be used in all the status updates; this is useful in cases where you need to use the same Twitter account for more than one application, so you can tell which one sent the alarm. |
void |
setTokenSecret(String value)
Sets the token secret obtained with the TwitterAuth program; this allows jAlarms to post status updates to the twitter account set up for the alarms. |
Methods inherited from class com.solab.alarms.AbstractAlarmChannel |
---|
getMinResendInterval, send, setMinResendInterval, shutdown |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TwitterChannel()
Method Detail |
---|
public void setApiUrl(String value) throws MalformedURLException
MalformedURLException
public String getApiUrl()
public void setPrefix(String value)
public void setAlarmSource(Set<String> value)
public void setAccessToken(String value)
public void setTokenSecret(String value)
@PostConstruct public void init() throws NoSuchAlgorithmException, MalformedURLException
NoSuchAlgorithmException
- if the HmacSHA1 algorithm is not available.
MalformedURLException
protected Runnable createSendTask(String msg, String src)
AbstractAlarmChannel
createSendTask
in class AbstractAlarmChannel
msg
- The message to be sent.src
- The alarm source. A channel can have different recipient lists depending on the alarm source.protected boolean hasSource(String alarmSource)
AbstractAlarmChannel
hasSource
in class AbstractAlarmChannel
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |