@ -33,10 +33,12 @@ import org.springframework.util.Assert;
@@ -33,10 +33,12 @@ import org.springframework.util.Assert;
import org.springframework.util.StringUtils ;
/ * *
* An implementation of { @link org . springframework . messaging . simp . SimpMessageSendingOperations } .
* An implementation of
* { @link org . springframework . messaging . simp . SimpMessageSendingOperations } .
*
* < p > Also provides methods for sending messages to a user . See
* { @link org . springframework . messaging . simp . user . UserDestinationResolver UserDestinationResolver }
* { @link org . springframework . messaging . simp . user . UserDestinationResolver
* UserDestinationResolver }
* for more on user destinations .
*
* @author Rossen Stoyanchev
@ -47,19 +49,19 @@ public class SimpMessagingTemplate extends AbstractMessageSendingTemplate<String
@@ -47,19 +49,19 @@ public class SimpMessagingTemplate extends AbstractMessageSendingTemplate<String
private final MessageChannel messageChannel ;
private String userDestinationPrefix = "/user/" ;
private MessageHeaderInitializer headerInitializer ;
private String destinationPrefix = "/user/" ;
private volatile long sendTimeout = - 1 ;
private MessageHeaderInitializer headerInitializer ;
/ * *
* Create a new { @link SimpMessagingTemplate } instance .
* @param messageChannel the message channel ( must not be { @code null } )
* /
public SimpMessagingTemplate ( MessageChannel messageChannel ) {
Assert . notNull ( messageChannel , "MessageChannel must not be null" ) ;
Assert . notNull ( messageChannel , "'messageChannel' must not be null" ) ;
this . messageChannel = messageChannel ;
}
@ -77,8 +79,8 @@ public class SimpMessagingTemplate extends AbstractMessageSendingTemplate<String
@@ -77,8 +79,8 @@ public class SimpMessagingTemplate extends AbstractMessageSendingTemplate<String
* @see org . springframework . messaging . simp . user . UserDestinationMessageHandler
* /
public void setUserDestinationPrefix ( String prefix ) {
Assert . hasText ( prefix , "'userD estinationPrefix' must not be empty" ) ;
this . userD estinationPrefix = prefix . endsWith ( "/" ) ? prefix : prefix + "/" ;
Assert . hasText ( prefix , "'d estinationPrefix' must not be empty" ) ;
this . d estinationPrefix = prefix . endsWith ( "/" ) ? prefix : prefix + "/" ;
}
@ -86,37 +88,37 @@ public class SimpMessagingTemplate extends AbstractMessageSendingTemplate<String
@@ -86,37 +88,37 @@ public class SimpMessagingTemplate extends AbstractMessageSendingTemplate<String
* Return the configured user destination prefix .
* /
public String getUserDestinationPrefix ( ) {
return this . userD estinationPrefix;
return this . d estinationPrefix;
}
/ * *
* Configure a { @link MessageHeaderInitializer } to apply to the headers of all
* messages created through the { @code SimpMessagingTemplate } .
* < p > By default , this property is not set .
* Specify the timeout value to use for send operations ( in milliseconds ) .
* /
public void setHeaderInitializer ( MessageHeaderInitializer headerInitializer ) {
this . headerInitializer = headerInitializer ;
public void setSendTimeout ( long sendTimeout ) {
this . sendTimeout = sendTimeout ;
}
/ * *
* Return the configured header initializer .
* Return the configured send timeout ( in milliseconds ) .
* /
public MessageHeaderInitializer getHeaderInitializer ( ) {
return this . headerInitializer ;
public long getSendTimeout ( ) {
return this . sendTimeout ;
}
/ * *
* Specify the timeout value to use for send operations ( in milliseconds ) .
* Configure a { @link MessageHeaderInitializer } to apply to the headers of all
* messages created through the { @code SimpMessagingTemplate } .
* < p > By default , this property is not set .
* /
public void setSendTimeout ( long sendTimeout ) {
this . sendTimeout = sendTimeout ;
public void setHeaderInitializer ( MessageHeaderInitializer headerInitializer ) {
this . headerInitializer = headerInitializer ;
}
/ * *
* Return the configured send timeout ( in milliseconds ) .
* Return the configured header initializer .
* /
public long getSendTimeout ( ) {
return this . sendTimeout ;
public MessageHeaderInitializer getHeaderInitializer ( ) {
return this . headerInitializer ;
}
@ -220,7 +222,7 @@ public class SimpMessagingTemplate extends AbstractMessageSendingTemplate<String
@@ -220,7 +222,7 @@ public class SimpMessagingTemplate extends AbstractMessageSendingTemplate<String
Assert . notNull ( user , "User must not be null" ) ;
user = StringUtils . replace ( user , "/" , "%2F" ) ;
super . convertAndSend ( this . userD estinationPrefix + user + destination , payload , headers , postProcessor ) ;
super . convertAndSend ( this . d estinationPrefix + user + destination , payload , headers , postProcessor ) ;
}