UserDestinationResolver that relies
on a SimpUserRegistry to find active sessions for a user.
When a user attempts to subscribe, e.g. to "/user/queue/position-updates", the "/user" prefix is removed and a unique suffix added based on the session id, e.g. "/queue/position-updates-useri9oqdfzo" to ensure different users can subscribe to the same logical destination without colliding.
When sending to a user, e.g. "/user/{username}/queue/position-updates", the "/user/{username}" prefix is removed and a suffix based on active session id's is added, e.g. "/queue/position-updates-useri9oqdfzo".
| Modifier and Type | Class and Description |
|---|---|
| private static class | DefaultUserDestinationResolver.
A temporary placeholder for a parsed source "user" destination. |
| Modifier and Type | Field and Description |
|---|---|
| private static final Log | |
| private String | |
| private boolean | |
| private final SimpUserRegistry |
| Access | Constructor and Description |
|---|---|
| public | DefaultUserDestinationResolver(SimpUserRegistry
the registry, never userRegistry)nullCreate an instance that will access user session id information through the provided registry. |
| Modifier and Type | Method and Description |
|---|---|
| protected boolean | |
| public String | |
| private Set | |
| public SimpUserRegistry | |
| protected String | Returns: a target destination, ornull if nonethe source destination from the input message. sourceDestination, String a subset of the destination without any user prefix. actualDestination, String the id of an active user session, never sessionId, String null.the target user, possibly user)null, e.g if not authenticated.This method determines how to translate the source "user" destination to an actual target destination for the given active user session. |
| public boolean | |
| private DefaultUserDestinationResolver. | |
| private DefaultUserDestinationResolver. | |
| private DefaultUserDestinationResolver. | |
| public UserDestinationResult | resolveDestination(Message<?>
the message to try to resolve message)Implements org. Resolve the given message with a user destination to one or more messages with actual destinations, one for each active user session. |
| public void | setRemoveLeadingSlash(boolean
whether to remove the leading slash remove)Use this property to indicate whether the leading slash from translated user destinations should be removed or not. |
| public void | setUserDestinationPrefix(String
the prefix to use prefix)The prefix used to identify user destinations. |
| public String |
| logger | back to summary |
|---|---|
| private static final Log logger | |
| prefix | back to summary |
|---|---|
| private String prefix | |
| removeLeadingSlash | back to summary |
|---|---|
| private boolean removeLeadingSlash | |
| userRegistry | back to summary |
|---|---|
| private final SimpUserRegistry userRegistry | |
| DefaultUserDestinationResolver | back to summary |
|---|---|
| public DefaultUserDestinationResolver(SimpUserRegistry userRegistry) Create an instance that will access user session id information through the provided registry.
| |
| checkDestination | back to summary |
|---|---|
| protected boolean checkDestination(String destination, String requiredPrefix) | |
| getDestinationPrefix | back to summary |
|---|---|
| public String getDestinationPrefix() Return the configured prefix for user destinations. | |
| getSessionIdsByUser | back to summary |
|---|---|
| private Set | |
| getSimpUserRegistry | back to summary |
|---|---|
| public SimpUserRegistry getSimpUserRegistry() Return the configured | |
| getTargetDestination | back to summary |
|---|---|
| protected String getTargetDestination(String sourceDestination, String actualDestination, String sessionId, String user) This method determines how to translate the source "user" destination to an actual target destination for the given active user session.
| |
| isRemoveLeadingSlash | back to summary |
|---|---|
| public boolean isRemoveLeadingSlash() Whether to remove the leading slash from target destinations.
| |
| parse | back to summary |
|---|---|
private DefaultUserDestinationResolver.
| |
| parseMessage | back to summary |
|---|---|
| private DefaultUserDestinationResolver. | |
| parseSubscriptionMessage | back to summary |
|---|---|
private DefaultUserDestinationResolver.
| |
| resolveDestination | back to summary |
|---|---|
| public UserDestinationResult resolveDestination(Message<?> message) Implements org. Doc from org. Resolve the given message with a user destination to one or more messages with actual destinations, one for each active user session.
| |
| setRemoveLeadingSlash | back to summary |
|---|---|
| public void setRemoveLeadingSlash(boolean remove) Use this property to indicate whether the leading slash from translated user destinations should be removed or not. This depends on the destination prefixes the message broker is configured with. By default this is set to
| |
| setUserDestinationPrefix | back to summary |
|---|---|
| public void setUserDestinationPrefix(String prefix) The prefix used to identify user destinations. Any destinations that do not start with the given prefix are not be resolved. The default prefix is "/user/".
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| Modifier and Type | Field and Description |
|---|---|
| private final String | |
| private final Set | |
| private final String | |
| private final String | |
| private final String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String | getActualDestination()
The actual destination, without any user prefix, e.g. "/queue/position-updates". |
| public Set | |
| public String | getSourceDestination()
The destination from the source message, e.g. "/user/{user}/queue/position-updates". |
| public String | getSubscribeDestination()
The user destination as it would be on a subscription, "/user/queue/position-updates". |
| public String |
| actualDestination | back to summary |
|---|---|
| private final String actualDestination | |
| sessionIds | back to summary |
|---|---|
| private final Set<String> sessionIds | |
| sourceDestination | back to summary |
|---|---|
| private final String sourceDestination | |
| subscribeDestination | back to summary |
|---|---|
| private final String subscribeDestination | |
| user | back to summary |
|---|---|
| private final String user
| |
| ParseResult | back to summary |
|---|---|
| public ParseResult(String sourceDest, String actualDest, String subscribeDest, Set<String> sessionIds, String user) | |
| getActualDestination | back to summary |
|---|---|
| public String getActualDestination() The actual destination, without any user prefix, e.g. "/queue/position-updates". | |
| getSessionIds | back to summary |
|---|---|
| public Set The session id or id's for the user. | |
| getSourceDestination | back to summary |
|---|---|
| public String getSourceDestination() The destination from the source message, e.g. "/user/{user}/queue/position-updates". | |
| getSubscribeDestination | back to summary |
|---|---|
| public String getSubscribeDestination() The user destination as it would be on a subscription, "/user/queue/position-updates". | |
| getUser | back to summary |
|---|---|
| public String getUser() The name of the user associated with the session.
| |