org.springframework.messaging.simp.user

## Class MultiServerUserRegistry

- java.lang.Object
- - org.springframework.messaging.simp.user.MultiServerUserRegistry

- All Implemented Interfaces:
    EventListener, ApplicationListener<ApplicationEvent>, SmartApplicationListener, Ordered, SimpUserRegistry

      public class MultiServerUserRegistry
      extends Object
      implements SimpUserRegistry, 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

- - ### Field Summary

    - ### Fields inherited from interface org.springframework.core.Ordered

      `HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MultiServerUserRegistry(SimpUserRegistry localRegistry)` Create an instance wrapping the local user registry.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Set<SimpSubscription>` | `findSubscriptions(SimpSubscriptionMatcher matcher)` Find subscriptions with the given matcher.
    `int` | `getOrder()` Determine this listener's order in a set of listeners for the same event.
    `SimpUser` | `getUser(String userName)` Get the user for the given name.
    `int` | `getUserCount()` Return the count of all connected users.
    `Set<SimpUser>` | `getUsers()` Return a snapshot of all connected users.
    `void` | `onApplicationEvent(ApplicationEvent event)` Handle an application event.
    `boolean` | `supportsEventType(Class<? extends ApplicationEvent> eventType)` Determine whether this listener actually supports the given event type.
    `boolean` | `supportsSourceType(Class<?> sourceType)` Determine whether this listener actually supports the given source type.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.springframework.context.event.SmartApplicationListener

      `getListenerId`

    - ### Methods inherited from interface org.springframework.context.ApplicationListener

      `forPayload`

- - ### Constructor Detail

    - #### MultiServerUserRegistry

          public MultiServerUserRegistry(SimpUserRegistry localRegistry)

      Create an instance wrapping the local user registry.

  - ### Method Detail

    - #### getOrder

          public int getOrder()

      Description copied from interface: `SmartApplicationListener`
      Determine this listener's order in a set of listeners for the same event.

      The default implementation returns `Ordered.LOWEST_PRECEDENCE`.

      Specified by:
        `getOrder` in interface `SmartApplicationListener`
      Specified by:
        `getOrder` in interface `Ordered`
      Returns:
        the order value
      See Also:
        `Ordered.HIGHEST_PRECEDENCE`, `Ordered.LOWEST_PRECEDENCE`

    - #### supportsEventType

          public boolean supportsEventType(Class<? extends ApplicationEvent> eventType)

      Description copied from interface: `SmartApplicationListener`
      Determine whether this listener actually supports the given event type.
      Specified by:
        `supportsEventType` in interface `SmartApplicationListener`
      Parameters:
        `eventType` - the event type (never `null`)

    - #### supportsSourceType

          public boolean supportsSourceType(@Nullable
                                            Class<?> sourceType)

      Description copied from interface: `SmartApplicationListener`
      Determine whether this listener actually supports the given source type.

      The default implementation always returns `true`.

      Specified by:
        `supportsSourceType` in interface `SmartApplicationListener`
      Parameters:
        `sourceType` - the source type, or `null` if no source

    - #### onApplicationEvent

          public void onApplicationEvent(ApplicationEvent event)

      Description copied from interface: `ApplicationListener`
      Handle an application event.
      Specified by:
        `onApplicationEvent` in interface `ApplicationListener<ApplicationEvent>`
      Parameters:
        `event` - the event to respond to

    - #### 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`