Class AbstractNotificationEventListener<T extends com.atlassian.event.Event>
- java.lang.Object
-
- 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
,ChainCompletedNotificationListener
,CommentNotificationListener
public abstract class AbstractNotificationEventListener<T extends com.atlassian.event.Event> extends Object implements HibernateEventListener
Base class for notification listeners
-
-
Field Summary
Fields Modifier and Type Field Description protected CachedPlanManager
cachedPlanManager
protected Class<T>
eventClass
protected NotificationDispatcher
notificationDispatcher
protected NotificationManager
notificationManager
protected Set<Class<? extends NotificationType>>
notificationTypeFilter
protected ResultsSummaryManager
resultsSummaryManager
protected SystemNotificationService
systemNotificationService
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractNotificationEventListener(Class<T> eventClass, Set<Class<? extends NotificationType>> notificationTypeFilter)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected ResultsSummary
fetchResultSummaryIfRequiredByNotificationRules(@NotNull PlanResultKey planResultKey, @NotNull Iterable<NotificationRule> notificationRules)
protected Iterable<NotificationRule>
filterNotificationRules(@NotNull Iterable<NotificationRule> iterable, T event)
Filter passed Iterable by list of classes in notificationTypeFilter and by call to NotificationType#isNotificationRequired(Event).Class<? extends com.atlassian.event.Event>[]
getHandledEventClasses()
protected Iterable<NotificationRule>
getNotificationRules(@NotNull ImmutablePlan plan, T event)
Return notification rules effective for a given plan and event.protected @Nullable ImmutablePlan
getPlan(T event)
Try to retrieve plan using data in the event.protected Iterable<NotificationRule>
getSystemNotificationRules(T event)
Return system notification rules effective for a given event.void
handleEvent(com.atlassian.event.Event event)
Implementation of HibernateEventListener#handleEventabstract void
handleEvent(T event, @NotNull ImmutablePlan plan)
Notification event listeners must implement this method to handle incoming events.void
setCachedPlanManager(CachedPlanManager cachedPlanManager)
void
setNotificationDispatcher(NotificationDispatcher notificationDispatcher)
void
setNotificationManager(NotificationManager notificationManager)
void
setResultsSummaryManager(ResultsSummaryManager resultsSummaryManager)
void
setSystemNotificationService(SystemNotificationService systemNotificationService)
-
-
-
Field Detail
-
notificationDispatcher
protected NotificationDispatcher notificationDispatcher
-
notificationManager
protected NotificationManager notificationManager
-
cachedPlanManager
protected CachedPlanManager cachedPlanManager
-
systemNotificationService
protected SystemNotificationService systemNotificationService
-
notificationTypeFilter
protected final Set<Class<? extends NotificationType>> notificationTypeFilter
-
resultsSummaryManager
protected ResultsSummaryManager resultsSummaryManager
-
-
Constructor Detail
-
AbstractNotificationEventListener
protected AbstractNotificationEventListener(Class<T> eventClass, Set<Class<? extends NotificationType>> notificationTypeFilter)
- Parameters:
eventClass
- Class of event this listener would listen tonotificationTypeFilter
- Set of notification types this listener is interested in
-
-
Method Detail
-
getHandledEventClasses
public Class<? extends com.atlassian.event.Event>[] getHandledEventClasses()
- Specified by:
getHandledEventClasses
in interfacecom.atlassian.event.EventListener
- Specified by:
getHandledEventClasses
in interfaceHibernateEventListener
-
getNotificationRules
protected Iterable<NotificationRule> getNotificationRules(@NotNull @NotNull ImmutablePlan 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 filteredevent
- 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 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 Iterable<NotificationRule> filterNotificationRules(@NotNull @NotNull 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 iterableevent
- 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 @NotNull ImmutablePlan 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 interfacecom.atlassian.event.EventListener
- Specified by:
handleEvent
in interfaceHibernateEventListener
- Parameters:
event
- Event to be handled
-
getPlan
@Nullable protected @Nullable ImmutablePlan 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
-
fetchResultSummaryIfRequiredByNotificationRules
protected ResultsSummary fetchResultSummaryIfRequiredByNotificationRules(@NotNull @NotNull PlanResultKey planResultKey, @NotNull @NotNull Iterable<NotificationRule> notificationRules)
-
setNotificationDispatcher
public void setNotificationDispatcher(NotificationDispatcher notificationDispatcher)
-
setNotificationManager
public void setNotificationManager(NotificationManager notificationManager)
-
setCachedPlanManager
public void setCachedPlanManager(CachedPlanManager cachedPlanManager)
-
setSystemNotificationService
public void setSystemNotificationService(SystemNotificationService systemNotificationService)
-
setResultsSummaryManager
public void setResultsSummaryManager(ResultsSummaryManager resultsSummaryManager)
-
-