当前位置: 首页>>代码示例>>Java>>正文


Java StompHeaderAccessor.getDestination方法代码示例

本文整理汇总了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);
        }
    }
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:24,代码来源:EventRouter.java

示例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;
}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:19,代码来源:TestChannelInterceptor.java

示例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;
}
 
开发者ID:wieden-kennedy,项目名称:composite-framework,代码行数:23,代码来源:TestChannelInterceptor.java

示例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;
}
 
开发者ID:luxons,项目名称:seven-wonders,代码行数:14,代码来源:TopicSubscriptionInterceptor.java

示例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);
}
 
开发者ID:learning-layers,项目名称:LivingDocumentsServer,代码行数:16,代码来源:MessageAuthenticationInterceptor.java


注:本文中的org.springframework.messaging.simp.stomp.StompHeaderAccessor.getDestination方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。