sk.baka.webvm.misc
Class NotificationDelivery

java.lang.Object
  extended by sk.baka.webvm.misc.BackgroundService
      extended by sk.baka.webvm.misc.NotificationDelivery

public final class NotificationDelivery
extends BackgroundService

Delivers miscellaneous notifications (mail, jabber).

Author:
Martin Vysny

Field Summary
 
Fields inherited from class sk.baka.webvm.misc.BackgroundService
maxThreads, name
 
Constructor Summary
NotificationDelivery()
          Creates new deliverer.
 
Method Summary
 void configure(Config config)
          Sets the new configuration file.
 void deliverAsync(List<ProblemReport> reports)
          Delivers given report asynchronously.
static boolean isEmailEnabled(Config config)
          Checks if sending mail is enabled in given config object.
static boolean isJabberEnabled(Config config)
          Checks if sending mail is enabled in given config object.
static void sendEmail(Config config, boolean testing, List<ProblemReport> reports)
          Sends a mail with given report.
static void sendJabber(Config config, boolean testing, List<ProblemReport> reports)
          Sends a Jabber message with the Problems analysis.
protected  void started(ScheduledExecutorService executor)
          Invoked when the service is started.
protected  void stopped()
          Invoked after the service has been stopped.
 
Methods inherited from class sk.baka.webvm.misc.BackgroundService
getExecutor, newDaemonFactory, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NotificationDelivery

public NotificationDelivery()
Creates new deliverer.

Method Detail

isEmailEnabled

public static boolean isEmailEnabled(Config config)
Checks if sending mail is enabled in given config object.

Parameters:
config - the configuration object
Returns:
true if Config.mailSmtpHost is non-empty, false otherwise.

isJabberEnabled

public static boolean isJabberEnabled(Config config)
Checks if sending mail is enabled in given config object.

Parameters:
config - the configuration object
Returns:
true if Config.mailSmtpHost is non-empty, false otherwise.

sendEmail

public static void sendEmail(Config config,
                             boolean testing,
                             List<ProblemReport> reports)
                      throws org.apache.commons.mail.EmailException
Sends a mail with given report.

Parameters:
config - the mail server configuration.
testing - if true then a testing mail is sent
reports - the current reports
Throws:
org.apache.commons.mail.EmailException - if sending mail fails.

sendJabber

public static void sendJabber(Config config,
                              boolean testing,
                              List<ProblemReport> reports)
                       throws org.jivesoftware.smack.XMPPException
Sends a Jabber message with the Problems analysis.

Parameters:
config - use this config.
testing - if true then a (testing) string is appended to the message
reports - use these reports
Throws:
org.jivesoftware.smack.XMPPException - when send fails

deliverAsync

public void deliverAsync(List<ProblemReport> reports)
Delivers given report asynchronously.

Parameters:
reports - the reports to deliver.

started

protected void started(ScheduledExecutorService executor)
Description copied from class: BackgroundService
Invoked when the service is started.

Specified by:
started in class BackgroundService
Parameters:
executor - executes tasks.

configure

public void configure(Config config)
Sets the new configuration file.

Parameters:
config - the new config file.

stopped

protected void stopped()
Description copied from class: BackgroundService
Invoked after the service has been stopped.

Specified by:
stopped in class BackgroundService


Copyright © 2010 Baka. All Rights Reserved.