org.sonar.api.notifications
Class NotificationDispatcher

java.lang.Object
  extended by org.sonar.api.notifications.NotificationDispatcher
All Implemented Interfaces:
Extension, ServerComponent, ServerExtension

public abstract class NotificationDispatcher
extends Object
implements ServerExtension

Plugins should extend this class to provide logic to determine which users are interested in receiving notifications, along with which delivery channels they selected.

For example:

Since:
2.10

Nested Class Summary
static interface NotificationDispatcher.Context
          Additional information related to the notification, which will be used to know who should receive the notification.
 
Constructor Summary
NotificationDispatcher()
          Creates a new generic dispatcher, used for any kind of notification.
NotificationDispatcher(String notificationType)
          Creates a new dispatcher for notifications of the given type.
 
Method Summary
abstract  void dispatch(Notification notification, NotificationDispatcher.Context context)
           Implements the logic that defines which users will receive the notification.
 String getKey()
          The unique key of this dispatcher.
 void performDispatch(Notification notification, NotificationDispatcher.Context context)
           Performs the dispatch.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NotificationDispatcher

public NotificationDispatcher(String notificationType)
Creates a new dispatcher for notifications of the given type.

Parameters:
notificationType - the type of notifications handled by this dispatcher

NotificationDispatcher

public NotificationDispatcher()
Creates a new generic dispatcher, used for any kind of notification.

Should be avoided and replaced by the other constructor - as it is easier to understand that a dispatcher listens for a specific type of notification.

Method Detail

getKey

public String getKey()
The unique key of this dispatcher. By default it's the class name without the package prefix.

The related label in l10n bundles is 'notification.dispatcher.', for example 'notification.dispatcher.NewFalsePositive'.


performDispatch

public final void performDispatch(Notification notification,
                                  NotificationDispatcher.Context context)

Performs the dispatch.


dispatch

public abstract void dispatch(Notification notification,
                              NotificationDispatcher.Context context)

Implements the logic that defines which users will receive the notification.

The purpose of this method is to populate the context object with users, based on the type of notification and the content of the notification.


toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009-2014 SonarSource. All Rights Reserved.