com.atlassian.bamboo.notification
Class AbstractNotificationEventListener<T extends com.atlassian.event.Event>

java.lang.Object
  extended by com.atlassian.bamboo.notification.AbstractNotificationEventListener<T>
Type Parameters:
T - Event to which this listener would listen to.
All Implemented Interfaces:
HibernateEventListener, com.atlassian.event.EventListener
Direct Known Subclasses:
AfterXFailedNotificationListener, BuildCompletedNotificationListener, BuildErrorNotificationListener, BuildHungNotificationListener, BuildMissingCapableAgentNotificationListener, BuildQueueTimeoutNotificationListener, CommentNotificationListener

public abstract class AbstractNotificationEventListener<T extends com.atlassian.event.Event>
extends java.lang.Object
implements HibernateEventListener

Base class for notification listeners


Field Summary
protected  java.lang.Class<T> eventClass
           
protected  NotificationDispatcher notificationDispatcher
           
protected  NotificationManager notificationManager
           
protected  java.util.Set<java.lang.Class<? extends NotificationType>> notificationTypeFilter
           
protected  PlanManager planManager
           
protected  SystemNotificationService systemNotificationService
           
 
Constructor Summary
protected AbstractNotificationEventListener(java.lang.Class<T> eventClass, java.util.Set<java.lang.Class<? extends NotificationType>> notificationTypeFilter)
           
 
Method Summary
protected
<N extends Notification>
N
createNotificationComponent(java.lang.Class<N> notificationClass)
          Creates Notification object using Spring
protected  java.lang.Iterable<NotificationRule> filterNotificationRules(java.lang.Iterable<NotificationRule> iterable, T event)
          Filter passed Iterable by list of classes in notificationTypeFilter and by call to NotificationType#isNotificationRequired(Event).
 java.lang.Class<? extends com.atlassian.event.Event>[] getHandledEventClasses()
           
protected  java.lang.Iterable<NotificationRule> getNotificationRules(Plan plan, T event)
          Return notification rules effective for a given plan and event.
protected  Plan getPlan(T event)
          Try to retrieve plan using data in the event.
protected  java.lang.Iterable<NotificationRule> getSystemNotificationRules(T event)
          Return system notification rules effective for a given event.
 void handleEvent(com.atlassian.event.Event event)
          Implementation of HibernateEventListener#handleEvent
abstract  void handleEvent(T event, Plan plan)
          Notification event listeners must implement this method to handle incoming events.
 void setNotificationDispatcher(NotificationDispatcher notificationDispatcher)
           
 void setNotificationManager(NotificationManager notificationManager)
           
 void setPlanManager(PlanManager planManager)
           
 void setSystemNotificationService(SystemNotificationService systemNotificationService)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

notificationDispatcher

protected NotificationDispatcher notificationDispatcher

notificationManager

protected NotificationManager notificationManager

planManager

protected PlanManager planManager

systemNotificationService

protected SystemNotificationService systemNotificationService

eventClass

protected final java.lang.Class<T extends com.atlassian.event.Event> eventClass

notificationTypeFilter

protected final java.util.Set<java.lang.Class<? extends NotificationType>> notificationTypeFilter
Constructor Detail

AbstractNotificationEventListener

protected AbstractNotificationEventListener(java.lang.Class<T> eventClass,
                                            java.util.Set<java.lang.Class<? extends NotificationType>> notificationTypeFilter)
Parameters:
eventClass - Class of event this listener would listen to
notificationTypeFilter - Set of notification types this listener is interested in
Method Detail

getHandledEventClasses

public java.lang.Class<? extends com.atlassian.event.Event>[] getHandledEventClasses()
Specified by:
getHandledEventClasses in interface HibernateEventListener
Specified by:
getHandledEventClasses in interface com.atlassian.event.EventListener
Returns:
Array of Class objects this listener handles

getNotificationRules

protected java.lang.Iterable<NotificationRule> getNotificationRules(@NotNull
                                                                    Plan plan,
                                                                    @NotNull
                                                                    T event)
Return notification rules effective for a given plan and event. List of notification rules from a plan is filtered by list of classes in notificationTypeFilter and by call to NotificationType#isNotificationRequired(Event).

Parameters:
plan - Plan which notification rules list will be filtered
event - Event which is being handled. It is passed to NotificationType#isNotificationRequired method to filter out notification rules
Returns:
Notification rules effective for a given plan and event

getSystemNotificationRules

protected java.lang.Iterable<NotificationRule> getSystemNotificationRules(@NotNull
                                                                          T event)
Return system notification rules effective for a given event. List of system notification rules is filtered by list of classes in notificationTypeFilter and by call to NotificationType#isNotificationRequired(Event).

Parameters:
event - Event which is being handled. It is passed to NotificationType#isNotificationRequired method to filter out notification rules
Returns:
System notification rules effective for a given event

filterNotificationRules

protected java.lang.Iterable<NotificationRule> filterNotificationRules(@NotNull
                                                                       java.lang.Iterable<NotificationRule> iterable,
                                                                       @NotNull
                                                                       T event)
Filter passed Iterable by list of classes in notificationTypeFilter and by call to NotificationType#isNotificationRequired(Event).

Parameters:
iterable - Input iterable
event - Event which is being handled. It is passed to NotificationType#isNotificationRequired method to filter out notification rules
Returns:
Filtered Iterable

handleEvent

public abstract void handleEvent(@NotNull
                                 T event,
                                 @NotNull
                                 Plan plan)
Notification event listeners must implement this method to handle incoming events.

Parameters:
event - event to be handled (narrowed to effective class of event being handled)
plan - plan which is related to event being handled

handleEvent

public void handleEvent(com.atlassian.event.Event event)
Implementation of HibernateEventListener#handleEvent

Specified by:
handleEvent in interface HibernateEventListener
Specified by:
handleEvent in interface com.atlassian.event.EventListener
Parameters:
event - Event to be handled

createNotificationComponent

protected <N extends Notification> N createNotificationComponent(java.lang.Class<N> notificationClass)
Creates Notification object using Spring

Type Parameters:
N -
Parameters:
notificationClass - Requested notification class
Returns:
Notification object created with Spring

getPlan

@Nullable
protected Plan getPlan(@NotNull
                                T event)
Try to retrieve plan using data in the event.

Parameters:
event - Event being handled
Returns:
Plan object referred by the event

setNotificationDispatcher

public void setNotificationDispatcher(NotificationDispatcher notificationDispatcher)

setNotificationManager

public void setNotificationManager(NotificationManager notificationManager)

setPlanManager

public void setPlanManager(PlanManager planManager)

setSystemNotificationService

public void setSystemNotificationService(SystemNotificationService systemNotificationService)


Copyright © 2010 Atlassian. All Rights Reserved.