本文整理汇总了Java中org.springframework.messaging.simp.stomp.StompHeaderAccessor.getDestination方法的典型用法代码示例。如果您正苦于以下问题:Java StompHeaderAccessor.getDestination方法的具体用法?Java StompHeaderAccessor.getDestination怎么用?Java StompHeaderAccessor.getDestination使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.messaging.simp.stomp.StompHeaderAccessor
的用法示例。
在下文中一共展示了StompHeaderAccessor.getDestination方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendHistoryToNewSubscriber
import org.springframework.messaging.simp.stomp.StompHeaderAccessor; //导入方法依赖的package包/类
private void sendHistoryToNewSubscriber(AbstractSubProtocolEvent ev) {
Message<byte[]> msg = ev.getMessage();
StompHeaderAccessor ha = StompHeaderAccessor.wrap(msg);
String pattern = ha.getDestination();
if(!pattern.startsWith(PREFIX)) {
// we must send only to appropriate paths
return;
}
MessageConverter messageConverter = this.simpMessagingTemplate.getMessageConverter();
for(BusData data: buses.values()) {
String dest = getDestination(data.getId());
if(!this.pathMatcher.match(pattern, dest)) {
continue;
}
for(Object obj: data.getEvents()) {
StompHeaderAccessor mha = Stomp.createHeaders(ha.getSessionId(), ha.getSubscriptionId());
mha.setDestination(dest);
Message<?> message = messageConverter.toMessage(obj, mha.getMessageHeaders());
clientChannel.send(message);
}
}
}
示例2: preSend
import org.springframework.messaging.simp.stomp.StompHeaderAccessor; //导入方法依赖的package包/类
@Override
public Message<?> preSend(Message<?> message, MessageChannel channel) {
if (this.destinationPatterns.isEmpty()) {
this.messages.add(message);
}
else {
StompHeaderAccessor headers = StompHeaderAccessor.wrap(message);
if (headers.getDestination() != null) {
for (String pattern : this.destinationPatterns) {
if (this.matcher.match(pattern, headers.getDestination())) {
this.messages.add(message);
break;
}
}
}
}
return message;
}
示例3: preSend
import org.springframework.messaging.simp.stomp.StompHeaderAccessor; //导入方法依赖的package包/类
@Override
public Message<?> preSend(Message<?> message, MessageChannel channel) {
if (this.isRecording) {
if (this.destinationPatterns.isEmpty()) {
this.messages.add(message);
}
else {
StompHeaderAccessor headers = StompHeaderAccessor.wrap(message);
if (headers.getDestination() != null) {
for (String pattern : this.destinationPatterns) {
if (this.matcher.match(pattern, headers.getDestination())) {
this.messages.add(message);
break;
}
}
}
}
}
return message;
}
示例4: preSend
import org.springframework.messaging.simp.stomp.StompHeaderAccessor; //导入方法依赖的package包/类
@Override
public Message<?> preSend(Message<?> message, MessageChannel channel) {
StompHeaderAccessor headerAccessor = StompHeaderAccessor.wrap(message);
if (StompCommand.SUBSCRIBE.equals(headerAccessor.getCommand())) {
String username = headerAccessor.getUser().getName();
String destination = headerAccessor.getDestination();
if (!destinationAccessValidator.hasAccess(username, destination)) {
sendForbiddenSubscriptionError(username, destination);
return null;
}
}
return message;
}
示例5: preSend
import org.springframework.messaging.simp.stomp.StompHeaderAccessor; //导入方法依赖的package包/类
@Override
public Message<?> preSend(Message<?> message, MessageChannel channel) {
StompHeaderAccessor headerAccessor = StompHeaderAccessor.wrap(message);
if (StompCommand.SUBSCRIBE.equals(headerAccessor.getCommand())) {
String destination = headerAccessor.getDestination();
Object headerAccessorUser = headerAccessor.getUser();
if (!(headerAccessorUser instanceof UsernamePasswordAuthenticationToken)) {
throw new IllegalArgumentException("User not set");
}
UsernamePasswordAuthenticationToken userToken = (UsernamePasswordAuthenticationToken) headerAccessorUser;
User user = (User) userToken.getPrincipal();
validateDestination(destination, user);
}
return super.preSend(message, channel);
}