Class ApplicationBadgeService

java.lang.Object
io.meeds.appcenter.service.ApplicationBadgeService

@Service public class ApplicationBadgeService extends Object
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 Details

    • BADGE_UPDATED_EVENT

      public static final String 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 identifier
      username - 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 name
      IllegalAccessException - when the badge is bound to no application the user may access
    • updateBadge

      public void updateBadge(String badgeName, String username)
      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 changed
      username - the user whose count changed
    • getBadgeProviders

      public List<ApplicationBadgeProvider> 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