Interface ApplicationBadgePlugin

All Known Implementing Classes:
WebNotificationApplicationBadgePlugin

public interface ApplicationBadgePlugin
Contributes an unread/pending counter — a "badge" — for one Application Center catalog entry. An addon implements this to make its own count appear on its application tile, in the app launcher, in the "My Applications" portlet and on the pinned topbar button, without any frontend code.

Implementations are discovered as Spring beans, or registered explicitly through ApplicationBadgePluginRegistry#addPlugin for addons still wired through Kernel XML.

A plugin carries no business logic: it transfers the call to its own domain's Service layer, and never reaches a DAO or a Storage bean.

  • Method Summary

    Modifier and Type
    Method
    Description
    long
    countBadge(String username)
    Counts the items this badge reports for one user.
    default List<String>
     
    default List<String>
     
    default List<String>
    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.
     
    default List<String>
    The portlets whose catalog entries carry this badge, preferably as applicationName/portletName content ids — unambiguous when two addons ship a portlet of the same name.
    default boolean
    isEnabled(String username)
    Lets a plugin opt a user out entirely, so that no count is ever computed for them.
    default boolean
    Whether this plugin owns its own caching, in which case App Center calls countBadge(String) directly instead of going through its own cache.
  • Method Details

    • getName

      String getName()
      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.
    • countBadge

      long countBadge(String username)
      Counts the items this badge reports for one user. Called on the read path, so it must be cheap — or the plugin must declare itself isSelfCached() and do its own caching.
      Parameters:
      username - the user the count is computed for
      Returns:
      the number of items to display, 0 to hide the badge
    • isEnabled

      default boolean isEnabled(String username)
      Lets a plugin opt a user out entirely, so that no count is ever computed for them. Typically used when the user has not connected the underlying account.
      Parameters:
      username - the user to test
      Returns:
      true when this badge applies to that user
    • isSelfCached

      default boolean isSelfCached()
      Whether this plugin owns its own caching, in which case App Center calls countBadge(String) directly instead of going through its own cache.

      Meant for a source whose lifecycle sits outside the container — a third-party system App Center can neither invalidate nor observe — and whose count must stay consistent with what the same addon displays elsewhere. Such a plugin owns both its caching and its single-flight: self-cached never means uncached.

      Returns:
      true to bypass the App Center badge cache
    • getDrawerNames

      default List<String> getDrawerNames()
      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.
      Returns:
      the url of every catalog entry of type DRAWER this badge belongs to, so that the binding resolves with no administrator action, empty when none
    • getPortletNames

      default List<String> getPortletNames()
      The portlets whose catalog entries carry this badge, preferably as applicationName/portletName content ids — unambiguous when two addons ship a portlet of the same name. A bare portlet-name is also accepted.

      Note this is not what a PORTLET entry stores: it stores the portlet instance id chosen in the administration suggester, and instance ids are generated per deployment so a plugin cannot know them. App Center maps one to the other.

      Returns:
      every portlet this badge belongs to, empty when none
      See Also:
    • getDeclaredUrls

      default List<String> getDeclaredUrls(ApplicationType type)
      Parameters:
      type - the catalog entry type to resolve against
      Returns:
      the urls this badge binds to for that type, never null
    • getDeclaredUrls

      default List<String> getDeclaredUrls()
      Returns:
      every url this badge binds to, whatever the entry type, never null