io.github.springwolf.plugins.stomp.asyncapi.scanners.common.MessageMappingUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of springwolf-stomp Show documentation
Show all versions of springwolf-stomp Show documentation
Automated JSON API documentation for STOMP listeners (websocket) built with Spring
The newest version!
// SPDX-License-Identifier: Apache-2.0
package io.github.springwolf.plugins.stomp.asyncapi.scanners.common;
import io.github.springwolf.asyncapi.v3.bindings.ChannelBinding;
import io.github.springwolf.asyncapi.v3.bindings.MessageBinding;
import io.github.springwolf.asyncapi.v3.bindings.OperationBinding;
import io.github.springwolf.asyncapi.v3.bindings.stomp.StompChannelBinding;
import io.github.springwolf.asyncapi.v3.bindings.stomp.StompMessageBinding;
import io.github.springwolf.asyncapi.v3.bindings.stomp.StompOperationBinding;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.util.StringValueResolver;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import static java.util.stream.Collectors.toList;
@Slf4j
public class MessageMappingUtil {
public static String getChannelName(MessageMapping annotation, StringValueResolver stringValueResolver) {
Stream destinations = Arrays.stream(annotation.value());
List resolvedDestinations =
destinations.map(stringValueResolver::resolveStringValue).collect(toList());
log.debug("Found destinations: {}", String.join(", ", resolvedDestinations));
return resolvedDestinations.get(0);
}
public static Map buildChannelBinding() {
return Map.of("stomp", new StompChannelBinding());
}
public static Map buildOperationBinding(
MessageMapping annotation, StringValueResolver stringValueResolver) {
StompOperationBinding binding = new StompOperationBinding();
return Map.of("stomp", binding);
}
public static Map buildMessageBinding() {
return Map.of("stomp", new StompMessageBinding());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy