Package io.meeds.appcenter.service
Class ApplicationBadgeService
java.lang.Object
io.meeds.appcenter.service.ApplicationBadgeService
Serves the per-user count displayed on an application tile, and propagates
its invalidation.
A count stays fresh in one of two ways, with no scheduled job on either side:
- through events, for a source whose changes the platform
can observe — the owning addon calls
updateBadge(String, String)from a glue listener; - through cache expiry then lazy recompute, for a source it cannot observe. Nothing is polled, so a user who never looks at their badges costs nothing.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringBroadcast after eviction; the glue listener turns it into a WebSocket frame. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongReads a badge count for one user.voidupdateBadge(String badgeName, String username) Invalidates a user's badge and tells their browser to refresh it.
-
Field Details
-
BADGE_UPDATED_EVENT
Broadcast after eviction; the glue listener turns it into a WebSocket frame.- See Also:
-
-
Constructor Details
-
ApplicationBadgeService
public ApplicationBadgeService()
-
-
Method Details
-
getBadge
public long getBadge(String badgeName, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Reads a badge count for one user.- Parameters:
badgeName- the badge identifierusername- the authenticated user, resolved by the caller from the session- Returns:
- the count, 0 when the badge does not apply to that user
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when no plugin is registered under that nameIllegalAccessException- when the badge is bound to no application the user may access
-
updateBadge
Invalidates a user's badge and tells their browser to refresh it.The eviction runs first, and the notification is only ever a broadcast: that ordering is what stops the browser from re-fetching the stale value it was just told to refresh.
- Parameters:
badgeName- the badge that changedusername- the user whose count changed
-
getBadgeProviders
- Returns:
- every registered badge provider with the urls it declares, so that the administration form can resolve an internal application's binding without asking anyone
-