Search in sources :

Example 1 with RSocketMessageHandler

use of org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler in project spring-security by spring-projects.

the class RSocketSecurity method build.

public PayloadSocketAcceptorInterceptor build() {
    PayloadSocketAcceptorInterceptor interceptor = new PayloadSocketAcceptorInterceptor(payloadInterceptors());
    RSocketMessageHandler handler = getBean(RSocketMessageHandler.class);
    interceptor.setDefaultDataMimeType(handler.getDefaultDataMimeType());
    interceptor.setDefaultMetadataMimeType(handler.getDefaultMetadataMimeType());
    return interceptor;
}
Also used : PayloadSocketAcceptorInterceptor(org.springframework.security.rsocket.core.PayloadSocketAcceptorInterceptor) RSocketMessageHandler(org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler)

Example 2 with RSocketMessageHandler

use of org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler in project spring-boot by spring-projects.

the class RSocketMessagingAutoConfiguration method messageHandler.

@Bean
@ConditionalOnMissingBean
public RSocketMessageHandler messageHandler(RSocketStrategies rSocketStrategies, ObjectProvider<RSocketMessageHandlerCustomizer> customizers) {
    RSocketMessageHandler messageHandler = new RSocketMessageHandler();
    messageHandler.setRSocketStrategies(rSocketStrategies);
    customizers.orderedStream().forEach((customizer) -> customizer.customize(messageHandler));
    return messageHandler;
}
Also used : RSocketMessageHandler(org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with RSocketMessageHandler

use of org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler in project spring-boot by spring-projects.

the class RSocketMessagingAutoConfigurationTests method shouldApplyMessageHandlerCustomizers.

@Test
void shouldApplyMessageHandlerCustomizers() {
    this.contextRunner.withUserConfiguration(CustomizerConfiguration.class).run((context) -> {
        RSocketMessageHandler handler = context.getBean(RSocketMessageHandler.class);
        assertThat(handler.getDefaultDataMimeType()).isEqualTo(MimeType.valueOf("application/json"));
    });
}
Also used : RSocketMessageHandler(org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler) Test(org.junit.jupiter.api.Test)

Example 4 with RSocketMessageHandler

use of org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler in project spring-framework by spring-projects.

the class RSocketBufferLeakTests method setupOnce.

@BeforeAll
void setupOnce() {
    context = new AnnotationConfigApplicationContext(ServerConfig.class);
    RSocketMessageHandler messageHandler = context.getBean(RSocketMessageHandler.class);
    SocketAcceptor responder = messageHandler.responder();
    server = RSocketServer.create(responder).payloadDecoder(PayloadDecoder.ZERO_COPY).interceptors(// intercept responding
    registry -> registry.forResponder(payloadInterceptor)).bind(TcpServerTransport.create("localhost", 7000)).block();
    requester = RSocketRequester.builder().rsocketConnector(conn -> conn.interceptors(registry -> registry.forRequester(payloadInterceptor))).rsocketStrategies(context.getBean(RSocketStrategies.class)).tcp("localhost", 7000);
}
Also used : Sinks(reactor.core.publisher.Sinks) BeforeEach(org.junit.jupiter.api.BeforeEach) StepVerifier(reactor.test.StepVerifier) RSocketMessageHandler(org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) CloseableChannel(io.rsocket.transport.netty.server.CloseableChannel) Controller(org.springframework.stereotype.Controller) Disabled(org.junit.jupiter.api.Disabled) PayloadDecoder(io.rsocket.frame.decoder.PayloadDecoder) RSocketServer(io.rsocket.core.RSocketServer) AfterAll(org.junit.jupiter.api.AfterAll) ApplicationErrorException(io.rsocket.exceptions.ApplicationErrorException) TestInstance(org.junit.jupiter.api.TestInstance) RSocket(io.rsocket.RSocket) BeforeAll(org.junit.jupiter.api.BeforeAll) Duration(java.time.Duration) Resource(org.springframework.core.io.Resource) Publisher(org.reactivestreams.Publisher) Mono(reactor.core.publisher.Mono) Instant(java.time.Instant) PooledByteBufAllocator(io.netty.buffer.PooledByteBufAllocator) SocketAcceptor(io.rsocket.SocketAcceptor) Lifecycle(org.junit.jupiter.api.TestInstance.Lifecycle) ReferenceCounted(io.netty.util.ReferenceCounted) MessageMapping(org.springframework.messaging.handler.annotation.MessageMapping) RSocketInterceptor(io.rsocket.plugins.RSocketInterceptor) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.jupiter.api.Test) Configuration(org.springframework.context.annotation.Configuration) Flux(reactor.core.publisher.Flux) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) MessageExceptionHandler(org.springframework.messaging.handler.annotation.MessageExceptionHandler) Payload(org.springframework.messaging.handler.annotation.Payload) TcpServerTransport(io.rsocket.transport.netty.server.TcpServerTransport) Bean(org.springframework.context.annotation.Bean) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) SocketAcceptor(io.rsocket.SocketAcceptor) RSocketMessageHandler(org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 5 with RSocketMessageHandler

use of org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler in project spring-framework by spring-projects.

the class RSocketServerToClientIntegrationTests method setupOnce.

@BeforeAll
@SuppressWarnings("ConstantConditions")
static void setupOnce() {
    context = new AnnotationConfigApplicationContext(RSocketConfig.class);
    RSocketMessageHandler messageHandler = context.getBean(RSocketMessageHandler.class);
    SocketAcceptor responder = messageHandler.responder();
    server = RSocketServer.create(responder).payloadDecoder(PayloadDecoder.ZERO_COPY).bind(TcpServerTransport.create("localhost", 0)).block();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) SocketAcceptor(io.rsocket.SocketAcceptor) RSocketMessageHandler(org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

RSocketMessageHandler (org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler)7 SocketAcceptor (io.rsocket.SocketAcceptor)3 BeforeAll (org.junit.jupiter.api.BeforeAll)3 Test (org.junit.jupiter.api.Test)3 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)3 Bean (org.springframework.context.annotation.Bean)2 PooledByteBufAllocator (io.netty.buffer.PooledByteBufAllocator)1 ReferenceCounted (io.netty.util.ReferenceCounted)1 RSocket (io.rsocket.RSocket)1 RSocketServer (io.rsocket.core.RSocketServer)1 ApplicationErrorException (io.rsocket.exceptions.ApplicationErrorException)1 PayloadDecoder (io.rsocket.frame.decoder.PayloadDecoder)1 WellKnownMimeType (io.rsocket.metadata.WellKnownMimeType)1 RSocketInterceptor (io.rsocket.plugins.RSocketInterceptor)1 CloseableChannel (io.rsocket.transport.netty.server.CloseableChannel)1 TcpServerTransport (io.rsocket.transport.netty.server.TcpServerTransport)1 Duration (java.time.Duration)1 Instant (java.time.Instant)1 List (java.util.List)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1