org.springframework.integration.rsocket.ServerRSocketMessageHandler Maven / Gradle / Ivy
Show all versions of spring-integration-rsocket Show documentation
/*
* Copyright 2019-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.rsocket;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;
import org.springframework.aot.hint.annotation.Reflective;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.handler.CompositeMessageCondition;
import org.springframework.messaging.handler.DestinationPatternsMessageCondition;
import org.springframework.messaging.rsocket.RSocketRequester;
import org.springframework.messaging.rsocket.annotation.support.RSocketFrameTypeMessageCondition;
import org.springframework.messaging.rsocket.annotation.support.RSocketRequesterMethodArgumentResolver;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;
/**
* An {@link IntegrationRSocketMessageHandler} extension for RSocket service side.
*
* In a plain Spring Integration application instances of this class are created by the
* {@link ServerRSocketConnector} internally and a new RSocket server is started over there.
* When an existing RSocket server is in use, an instance of this class has to be
* provided as a {@link #responder()} into that server and a {@link ServerRSocketConnector}
* should accept the same instance as a delegate.
*
* With a {@link #messageMappingCompatible} option this class also handles
* {@link org.springframework.messaging.handler.annotation.MessageMapping} methods,
* covering both Spring Integration and standard
* {@link org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler}
* functionality.
*
* @author Artem Bilan
*
* @since 5.2.1
*/
public class ServerRSocketMessageHandler extends IntegrationRSocketMessageHandler
implements ApplicationEventPublisherAware {
private static final Method HANDLE_CONNECTION_SETUP_METHOD =
ReflectionUtils.findMethod(ServerRSocketMessageHandler.class, "handleConnectionSetup", Message.class);
private final Map