Search in sources :

Example 1 with SubscribeMapping

use of org.springframework.messaging.simp.annotation.SubscribeMapping 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

Nullable (org.springframework.lang.Nullable)1 MessageMapping (org.springframework.messaging.handler.annotation.MessageMapping)1 SimpMessageMappingInfo (org.springframework.messaging.simp.SimpMessageMappingInfo)1 SubscribeMapping (org.springframework.messaging.simp.annotation.SubscribeMapping)1