Search in sources :

Example 11 with MessageMapping

use of org.springframework.messaging.handler.annotation.MessageMapping in project spring-framework by spring-projects.

the class SimpAnnotationMethodMessageHandler method getMappingForMethod.

@Override
@Nullable
protected SimpMessageMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
    MessageMapping messageAnn = AnnotatedElementUtils.findMergedAnnotation(method, MessageMapping.class);
    if (messageAnn != null) {
        MessageMapping typeAnn = AnnotatedElementUtils.findMergedAnnotation(handlerType, MessageMapping.class);
        // otherwise @MessageMapping is just being used as a (meta-annotation) marker.
        if (messageAnn.value().length > 0 || (typeAnn != null && typeAnn.value().length > 0)) {
            SimpMessageMappingInfo result = createMessageMappingCondition(messageAnn.value());
            if (typeAnn != null) {
                result = createMessageMappingCondition(typeAnn.value()).combine(result);
            }
            return result;
        }
    }
    SubscribeMapping subscribeAnn = AnnotatedElementUtils.findMergedAnnotation(method, SubscribeMapping.class);
    if (subscribeAnn != null) {
        MessageMapping typeAnn = AnnotatedElementUtils.findMergedAnnotation(handlerType, MessageMapping.class);
        // otherwise @SubscribeMapping is just being used as a (meta-annotation) marker.
        if (subscribeAnn.value().length > 0 || (typeAnn != null && typeAnn.value().length > 0)) {
            SimpMessageMappingInfo result = createSubscribeMappingCondition(subscribeAnn.value());
            if (typeAnn != null) {
                result = createMessageMappingCondition(typeAnn.value()).combine(result);
            }
            return result;
        }
    }
    return null;
}
Also used : SubscribeMapping(org.springframework.messaging.simp.annotation.SubscribeMapping) SimpMessageMappingInfo(org.springframework.messaging.simp.SimpMessageMappingInfo) MessageMapping(org.springframework.messaging.handler.annotation.MessageMapping) Nullable(org.springframework.lang.Nullable)

Aggregations

MessageMapping (org.springframework.messaging.handler.annotation.MessageMapping)11 SendTo (org.springframework.messaging.handler.annotation.SendTo)6 Room (com.mapia.domain.Room)4 ResponseMessage (com.hry.spring.mvc.websocket.model.ResponseMessage)3 Nullable (org.springframework.lang.Nullable)3 CompositeMessageCondition (org.springframework.messaging.handler.CompositeMessageCondition)2 DestinationPatternsMessageCondition (org.springframework.messaging.handler.DestinationPatternsMessageCondition)2 Map (java.util.Map)1 lombok.val (lombok.val)1 ConnectMapping (org.springframework.messaging.rsocket.annotation.ConnectMapping)1 SimpMessageMappingInfo (org.springframework.messaging.simp.SimpMessageMappingInfo)1 SendToUser (org.springframework.messaging.simp.annotation.SendToUser)1 SubscribeMapping (org.springframework.messaging.simp.annotation.SubscribeMapping)1 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)1