Class AbstractNotificationEventListener<T extends BambooEvent>
java.lang.Object
com.atlassian.bamboo.notification.AbstractNotificationEventListener<T>
- Type Parameters:
T- Event to which this listener would listen to.
- All Implemented Interfaces:
BambooEventListener<T>,HibernateEventListener<T>
- Direct Known Subclasses:
AfterXFailedNotificationListener,BuildCompletedNotificationListener,BuildErrorNotificationListener,BuildHungNotificationListener,BuildMissingCapableAgentNotificationListener,BuildQueueTimeoutNotificationListener,ChainCompletedNotificationListener,CommentNotificationListener
public abstract class AbstractNotificationEventListener<T extends BambooEvent>
extends Object
implements HibernateEventListener<T>
Base class for notification listeners
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CachedPlanManagerprotected NotificationDispatcherprotected NotificationManagerprotected final Set<Class<? extends NotificationType>>protected ResultsSummaryManagerprotected SystemNotificationService -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractNotificationEventListener(Class<T> eventClass, Set<Class<? extends NotificationType>> notificationTypeFilter) -
Method Summary
Modifier and TypeMethodDescriptionprotected ResultsSummaryfetchResultSummaryIfRequiredByNotificationRules(@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).List of specific event classes that this listener is interested in.protected Iterable<NotificationRule>getNotificationRules(@NotNull ImmutablePlan plan, T event) Return notification rules effective for a given plan and event.protected @Nullable ImmutablePlanTry to retrieve plan using data in the event.protected Iterable<NotificationRule>getSystemNotificationRules(T event) Return system notification rules effective for a given event.voidhandleEvent(BambooEvent event) The event handler.abstract voidhandleEvent(T event, @NotNull ImmutablePlan plan) Notification event listeners must implement this method to handle incoming events.voidsetCachedPlanManager(CachedPlanManager cachedPlanManager) voidsetNotificationDispatcher(NotificationDispatcher notificationDispatcher) voidsetNotificationManager(NotificationManager notificationManager) voidsetResultsSummaryManager(ResultsSummaryManager resultsSummaryManager) voidsetSystemNotificationService(SystemNotificationService systemNotificationService)
-
Field Details
-
notificationDispatcher
-
notificationManager
-
cachedPlanManager
-
systemNotificationService
-
eventClass
-
notificationTypeFilter
-
resultsSummaryManager
-
-
Constructor Details
-
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 Details
-
getHandledEventClasses
Description copied from interface:BambooEventListenerList of specific event classes that this listener is interested in.- Specified by:
getHandledEventClassesin interfaceBambooEventListener<T extends BambooEvent>- Returns:
- the specific event classes handled by this listener
-
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
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
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
The event handler. After running some generic checks, the logic to handle the event is delegated to child classes that implementhandleEvent(T, ImmutablePlan)method.- Specified by:
handleEventin interfaceBambooEventListener<T extends BambooEvent>- Parameters:
event- Event to be handled
-
getPlan
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
-
setNotificationManager
-
setCachedPlanManager
-
setSystemNotificationService
-
setResultsSummaryManager
-