public class MultiServerUserRegistry extends java.lang.Object implements SimpUserRegistry, SmartApplicationListener
UserRegistryMessageHandler
which broadcasts periodically the content
of the local registry and receives updates from other servers.Modifier and Type | Class and Description |
---|---|
private static class |
MultiServerUserRegistry.NoOpSmartApplicationListener |
private static class |
MultiServerUserRegistry.SimpSessionDto |
private static class |
MultiServerUserRegistry.SimpSubscriptionDto |
private static class |
MultiServerUserRegistry.SimpUserDto |
private static class |
MultiServerUserRegistry.UserRegistryDto |
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
id |
private SmartApplicationListener |
listener |
private SimpUserRegistry |
localRegistry |
private java.util.Map<java.lang.String,MultiServerUserRegistry.UserRegistryDto> |
remoteRegistries |
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
MultiServerUserRegistry(SimpUserRegistry localRegistry)
Create an instance wrapping the local user registry.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
addRemoteRegistryDto(Message<?> message,
MessageConverter converter,
long expirationPeriod) |
java.util.Set<SimpSubscription> |
findSubscriptions(SimpSubscriptionMatcher matcher)
Find subscriptions with the given matcher.
|
private static java.lang.String |
generateId() |
(package private) java.lang.Object |
getLocalRegistryDto() |
int |
getOrder()
Get the order value of this object.
|
SimpUser |
getUser(java.lang.String userName)
Get the user for the given name.
|
java.util.Set<SimpUser> |
getUsers()
Return a snapshot of all connected users.
|
void |
onApplicationEvent(ApplicationEvent event)
Handle an application event.
|
(package private) void |
purgeExpiredRegistries() |
boolean |
supportsEventType(java.lang.Class<? extends ApplicationEvent> eventType)
Determine whether this listener actually supports the given event type.
|
boolean |
supportsSourceType(java.lang.Class<?> sourceType)
Determine whether this listener actually supports the given source type.
|
java.lang.String |
toString() |
private final java.lang.String id
private final SimpUserRegistry localRegistry
private final SmartApplicationListener listener
private final java.util.Map<java.lang.String,MultiServerUserRegistry.UserRegistryDto> remoteRegistries
public MultiServerUserRegistry(SimpUserRegistry localRegistry)
private static java.lang.String generateId()
public SimpUser getUser(java.lang.String userName)
SimpUserRegistry
getUser
in interface SimpUserRegistry
userName
- the name of the user to look upnull
if not connectedpublic java.util.Set<SimpUser> getUsers()
SimpUserRegistry
getUsers
in interface SimpUserRegistry
public java.util.Set<SimpSubscription> findSubscriptions(SimpSubscriptionMatcher matcher)
SimpUserRegistry
findSubscriptions
in interface SimpUserRegistry
matcher
- the matcher to usepublic boolean supportsEventType(java.lang.Class<? extends ApplicationEvent> eventType)
SmartApplicationListener
supportsEventType
in interface SmartApplicationListener
public boolean supportsSourceType(java.lang.Class<?> sourceType)
SmartApplicationListener
supportsSourceType
in interface SmartApplicationListener
public void onApplicationEvent(ApplicationEvent event)
ApplicationListener
onApplicationEvent
in interface ApplicationListener<ApplicationEvent>
event
- the event to respond topublic int getOrder()
Ordered
Higher values are interpreted as lower priority. As a consequence,
the object with the lowest value has the highest priority (somewhat
analogous to Servlet load-on-startup
values).
Same order values will result in arbitrary sort positions for the affected objects.
getOrder
in interface Ordered
Ordered.HIGHEST_PRECEDENCE
,
Ordered.LOWEST_PRECEDENCE
java.lang.Object getLocalRegistryDto()
void addRemoteRegistryDto(Message<?> message, MessageConverter converter, long expirationPeriod)
void purgeExpiredRegistries()
public java.lang.String toString()
toString
in class java.lang.Object