Class DefaultUserDestinationResolver
- All Implemented Interfaces:
- UserDestinationResolver
UserDestinationResolver that relies
 on a SimpUserRegistry to find active sessions for a user.
 When a user attempts to subscribe, for example, to "/user/queue/position-updates", the "/user" prefix is removed and a unique suffix added based on the session id, for example, "/queue/position-updates-useri9oqdfzo" to ensure different users can subscribe to the same logical destination without colliding.
When sending to a user, for example, "/user/{username}/queue/position-updates", the "/user/{username}" prefix is removed and a suffix based on active session id's is added, for example, "/queue/position-updates-useri9oqdfzo".
- Since:
- 4.0
- Author:
- Rossen Stoyanchev, Brian Clozel
- 
Constructor SummaryConstructorsConstructorDescriptionDefaultUserDestinationResolver(SimpUserRegistry userRegistry) Create an instance that will access user session id information through the provided registry.
- 
Method SummaryModifier and TypeMethodDescriptionprotected booleancheckDestination(String destination, String requiredPrefix) Return the configured prefix for user destinations.Return the configuredSimpUserRegistry.protected StringgetTargetDestination(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.booleanWhether to remove the leading slash from target destinations.resolveDestination(Message<?> message) Resolve the given message with a user destination to one or more messages with actual destinations, one for each active user session.voidsetRemoveLeadingSlash(boolean remove) Use this property to indicate whether the leading slash from translated user destinations should be removed or not.voidsetUserDestinationPrefix(String prefix) The prefix used to identify user destinations.toString()
- 
Constructor Details- 
DefaultUserDestinationResolverCreate an instance that will access user session id information through the provided registry.- Parameters:
- userRegistry- the registry, never- null
 
 
- 
- 
Method Details- 
getSimpUserRegistryReturn the configuredSimpUserRegistry.
- 
setUserDestinationPrefixThe 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/". - Parameters:
- prefix- the prefix to use
 
- 
getDestinationPrefixReturn the configured prefix for user destinations.
- 
setRemoveLeadingSlashpublic 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 false, i.e. "do not change the target destination", althoughAbstractMessageBrokerConfigurationmay change that totrueif the configured destinations do not have a leading slash.- Parameters:
- remove- whether to remove the leading slash
- Since:
- 4.3.14
 
- 
isRemoveLeadingSlashpublic boolean isRemoveLeadingSlash()Whether to remove the leading slash from target destinations.- Since:
- 4.3.14
 
- 
resolveDestinationDescription copied from interface:UserDestinationResolverResolve the given message with a user destination to one or more messages with actual destinations, one for each active user session.- Specified by:
- resolveDestinationin interface- UserDestinationResolver
- Parameters:
- message- the message to try to resolve
- Returns:
- 0 or more target messages (one for each active session), or
 nullif the source message does not contain a user destination.
 
- 
checkDestination
- 
getTargetDestination@Nullable protected String getTargetDestination(String sourceDestination, String actualDestination, String sessionId, @Nullable String user) This method determines how to translate the source "user" destination to an actual target destination for the given active user session.- Parameters:
- sourceDestination- the source destination from the input message.
- actualDestination- a subset of the destination without any user prefix.
- sessionId- the id of an active user session, never- null.
- user- the target user, possibly- null,, for example, if not authenticated.
- Returns:
- a target destination, or nullif none
 
- 
toString
 
-