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
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionMultiServerUserRegistry(SimpUserRegistry localRegistry) Create an instance wrapping the local user registry. -
Method Summary
Modifier and TypeMethodDescriptionfindSubscriptions(SimpSubscriptionMatcher matcher) Find subscriptions with the given matcher.intgetOrder()Get the user for the given name.intReturn the count of all connected users.getUsers()Return a snapshot of all connected users.voidonApplicationEvent(org.springframework.context.ApplicationEvent event) booleansupportsEventType(Class<? extends org.springframework.context.ApplicationEvent> eventType) booleansupportsSourceType(@Nullable Class<?> sourceType) toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecutionMethods inherited from interface org.springframework.context.event.SmartApplicationListener
getListenerId
-
Constructor Details
-
MultiServerUserRegistry
Create an instance wrapping the local user registry.
-
-
Method Details
-
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered- Specified by:
getOrderin interfaceorg.springframework.context.event.SmartApplicationListener
-
supportsEventType
public boolean supportsEventType(Class<? extends org.springframework.context.ApplicationEvent> eventType) - Specified by:
supportsEventTypein interfaceorg.springframework.context.event.SmartApplicationListener
-
supportsSourceType
-
onApplicationEvent
public void onApplicationEvent(org.springframework.context.ApplicationEvent event) - Specified by:
onApplicationEventin interfaceorg.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
-
getUser
Description copied from interface:SimpUserRegistryGet the user for the given name.- Specified by:
getUserin interfaceSimpUserRegistry- Parameters:
userName- the name of the user to look up- Returns:
- the user, or
nullif not connected
-
getUsers
Description copied from interface:SimpUserRegistryReturn a snapshot of all connected users.The returned set is a copy and will not reflect further changes.
- Specified by:
getUsersin interfaceSimpUserRegistry- Returns:
- the connected users, or an empty set if none
-
getUserCount
public int getUserCount()Description copied from interface:SimpUserRegistryReturn the count of all connected users.- Specified by:
getUserCountin interfaceSimpUserRegistry- Returns:
- the number of connected users
-
findSubscriptions
Description copied from interface:SimpUserRegistryFind subscriptions with the given matcher.- Specified by:
findSubscriptionsin interfaceSimpUserRegistry- Parameters:
matcher- the matcher to use- Returns:
- a set of matching subscriptions, or an empty set if none
-
toString
-