com.solab.alarms
Class AlarmSender

java.lang.Object
  extended by com.solab.alarms.AlarmSender

public class AlarmSender
extends Object

This is the central class for jAlarms. An AlarmSender can have several AlarmChannel instances to send alarms through different channels to different people.

Author:
Enrique Zamudio

Constructor Summary
AlarmSender()
           
 
Method Summary
 int getAlarmTimeBuffer()
           
 String getStatus()
           
 void init()
          Sets up a ScheduledExecutorService if necessary, to buffer alarm messages that are supposed to be sent always.
 void sendAlarm(String msg)
          Sends an alarm through all channels, to the default users defined for each channel, as long as the message hasn't been already sent very recently.
 void sendAlarm(String msg, String source)
          Sends an alarm through all channels, to the users defined for the specified source in each channel, as long as the message hasn't been already sent very recently.
 void sendAlarmAlways(String msg)
          Sends an alarm through all channels, to the default users defined for each channel, regardless of the last time the same message was sent.
 void sendAlarmAlways(String msg, String source)
          Sends an alarm through all channels, to the users defined for the specified source in each channel, regardless of the last time the same message was sent.
 void setAlarmCache(AlarmCache value)
          Sets the cache to use for alarm messages.
 void setAlarmChannels(List<AlarmChannel> channels)
          Sets the alarm channels to be used for sending alarm messages.
 void setAlarmTimeBuffer(int value)
          Sets the time in milliseconds that the alarms sent via sendAlarmAlways(String, String) are buffered before actually sending them.
 void shutdown()
          Shuts down all channels, and the alarm cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AlarmSender

public AlarmSender()
Method Detail

setAlarmTimeBuffer

public void setAlarmTimeBuffer(int value)
Sets the time in milliseconds that the alarms sent via sendAlarmAlways(String, String) are buffered before actually sending them. Default is 0 which causes alarms to be sent immediately. If set to a positive value, alarms are not sent immediately, but are rather queued to be sent after sitting for the time specified here. If several identical messages are queued, only one is sent, specifying how many times it was received. The queue is reviewed every 30 seconds, which means that alarms will always be transmitted no sooner than 30 to 60 seconds after they're received, if they were only received one time; an alarm that's been received 2 or more times will be queued for as long as the buffer specifies.


getAlarmTimeBuffer

public int getAlarmTimeBuffer()

setAlarmCache

public void setAlarmCache(AlarmCache value)
Sets the cache to use for alarm messages.


setAlarmChannels

public void setAlarmChannels(List<AlarmChannel> channels)
Sets the alarm channels to be used for sending alarm messages.


sendAlarm

public void sendAlarm(String msg,
                      String source)
Sends an alarm through all channels, to the users defined for the specified source in each channel, as long as the message hasn't been already sent very recently. If the message is sent, the time is recorded to avoid further sending until the interval has elapsed for each channel.

Parameters:
msg - The message to be sent as an alarm.
source - The alarm source. The channels can use this information to determine the recipients of the alarm. If null, the default recipients for each channel are used.

sendAlarmAlways

public void sendAlarmAlways(String msg,
                            String source)
Sends an alarm through all channels, to the users defined for the specified source in each channel, regardless of the last time the same message was sent.

Parameters:
msg - The alarm message to be sent through the channels.
source - The alarm source. The channels can use this information to determine the recipients of the alarm. If null, the default recipients for each channel are used.

sendAlarm

public void sendAlarm(String msg)
Sends an alarm through all channels, to the default users defined for each channel, as long as the message hasn't been already sent very recently. If the message is sent, the time is recorded to avoid further sending until the interval has elapsed for each channel.


sendAlarmAlways

public void sendAlarmAlways(String msg)
Sends an alarm through all channels, to the default users defined for each channel, regardless of the last time the same message was sent.


init

@PostConstruct
public void init()
Sets up a ScheduledExecutorService if necessary, to buffer alarm messages that are supposed to be sent always.


shutdown

@PreDestroy
public void shutdown()
Shuts down all channels, and the alarm cache.


getStatus

public String getStatus()


Copyright © 2011 Java Mexico. All Rights Reserved.