Package io.meeds.appcenter.plugin
Class WebNotificationApplicationBadgePlugin
java.lang.Object
io.meeds.appcenter.plugin.WebNotificationApplicationBadgePlugin
- All Implemented Interfaces:
ApplicationBadgePlugin
@Component
public class WebNotificationApplicationBadgePlugin
extends Object
implements ApplicationBadgePlugin
Reports the notification centre counter on its Application Center tile.
Reuses WebNotificationService.getNumberOnBadge(String) — the very
value topbarNotification.jsp renders on the topbar bell — so the tile
and the bell are two views of one number and can never disagree. Note this is
deliberately not an unread count: it counts what the user has
not yet seen, and is reset wholesale when they open the drawer, exactly as the
bell behaves today.
Unlike the other contributors, this plugin lives in App Center rather than in
the addon owning the data: notifications live in commons, which sits
below App Center in the dependency tree, so it cannot depend back on
the badge SPI.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongcountBadge(String username) Counts the items this badge reports for one user.A badge may legitimately belong to several catalog entries — an application and its timeline or dashboard variant report the same counter — so several urls may be declared.getName()voidinit()booleanThe notification domain already caches this counter — with single-flight, throughCachedWebNotificationStorage'sFutureExoCache— and invalidates it on every notification change.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.meeds.appcenter.plugin.ApplicationBadgePlugin
getDeclaredUrls, getDeclaredUrls, getPortletNames, isEnabled
-
Field Details
-
BADGE_NAME
- See Also:
-
-
Constructor Details
-
WebNotificationApplicationBadgePlugin
public WebNotificationApplicationBadgePlugin()
-
-
Method Details
-
init
@PostConstruct public void init() -
getName
- Specified by:
getNamein interfaceApplicationBadgePlugin- Returns:
- the stable identifier of this badge, e.g.
agendaPendingInvitations. It is what an administrator binds to a catalog entry, and what travels on the WebSocket frame — so it must never change once released.
-
getDrawerNames
Description copied from interface:ApplicationBadgePluginA badge may legitimately belong to several catalog entries — an application and its timeline or dashboard variant report the same counter — so several urls may be declared.- Specified by:
getDrawerNamesin interfaceApplicationBadgePlugin- Returns:
- the
urlof every catalog entry of typeDRAWERthis badge belongs to, so that the binding resolves with no administrator action, empty when none
-
isSelfCached
public boolean isSelfCached()The notification domain already caches this counter — with single-flight, throughCachedWebNotificationStorage'sFutureExoCache— and invalidates it on every notification change. Caching it a second time in App Center would be two caches over one value with independent eviction, which is precisely the stale-badge pattern the design rejects.- Specified by:
isSelfCachedin interfaceApplicationBadgePlugin- Returns:
trueto bypass the App Center badge cache
-
countBadge
Description copied from interface:ApplicationBadgePluginCounts the items this badge reports for one user. Called on the read path, so it must be cheap — or the plugin must declare itselfApplicationBadgePlugin.isSelfCached()and do its own caching.- Specified by:
countBadgein interfaceApplicationBadgePlugin- Parameters:
username- the user the count is computed for- Returns:
- the number of items to display,
0to hide the badge
-