Class MultiServerUserRegistry

java.lang.Object
org.springframework.messaging.simp.user.MultiServerUserRegistry
All Implemented Interfaces:
EventListener, org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>, org.springframework.context.event.SmartApplicationListener, org.springframework.core.Ordered, SimpUserRegistry

public class MultiServerUserRegistry extends Object implements SimpUserRegistry, org.springframework.context.event.SmartApplicationListener
SimpUserRegistry that looks up users in a "local" user registry as well as a set of "remote" user registries. The local registry is provided as a constructor argument while remote registries are updated via broadcasts handled by UserRegistryMessageHandler which in turn notifies this registry when updates are received.
Since:
4.2
Author:
Rossen Stoyanchev
  • Constructor Details

    • MultiServerUserRegistry

      public MultiServerUserRegistry(SimpUserRegistry localRegistry)
      Create an instance wrapping the local user registry.
  • Method Details

    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface org.springframework.core.Ordered
      Specified by:
      getOrder in interface org.springframework.context.event.SmartApplicationListener
    • supportsEventType

      public boolean supportsEventType(Class<? extends org.springframework.context.ApplicationEvent> eventType)
      Specified by:
      supportsEventType in interface org.springframework.context.event.SmartApplicationListener
    • supportsSourceType

      public boolean supportsSourceType(@Nullable Class<?> sourceType)
      Specified by:
      supportsSourceType in interface org.springframework.context.event.SmartApplicationListener
    • onApplicationEvent

      public void onApplicationEvent(org.springframework.context.ApplicationEvent event)
      Specified by:
      onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
    • getUser

      @Nullable public SimpUser getUser(String userName)
      Description copied from interface: SimpUserRegistry
      Get the user for the given name.
      Specified by:
      getUser in interface SimpUserRegistry
      Parameters:
      userName - the name of the user to look up
      Returns:
      the user, or null if not connected
    • getUsers

      public Set<SimpUser> getUsers()
      Description copied from interface: SimpUserRegistry
      Return a snapshot of all connected users.

      The returned set is a copy and will not reflect further changes.

      Specified by:
      getUsers in interface SimpUserRegistry
      Returns:
      the connected users, or an empty set if none
    • getUserCount

      public int getUserCount()
      Description copied from interface: SimpUserRegistry
      Return the count of all connected users.
      Specified by:
      getUserCount in interface SimpUserRegistry
      Returns:
      the number of connected users
    • findSubscriptions

      public Set<SimpSubscription> findSubscriptions(SimpSubscriptionMatcher matcher)
      Description copied from interface: SimpUserRegistry
      Find subscriptions with the given matcher.
      Specified by:
      findSubscriptions in interface SimpUserRegistry
      Parameters:
      matcher - the matcher to use
      Returns:
      a set of matching subscriptions, or an empty set if none
    • toString

      public String toString()
      Overrides:
      toString in class Object