Class ServerRSocketConnector

java.lang.Object
org.springframework.integration.rsocket.AbstractRSocketConnector
org.springframework.integration.rsocket.ServerRSocketConnector
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.SmartInitializingSingleton, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationEventPublisherAware, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle

public class ServerRSocketConnector
extends AbstractRSocketConnector
implements org.springframework.context.ApplicationEventPublisherAware
A server AbstractRSocketConnector extension to accept and manage client RSocket connections.
Since:
5.2
See Also:
RSocketConnector
  • Field Summary

    Fields inherited from class org.springframework.integration.rsocket.AbstractRSocketConnector

    rSocketMessageHandler

    Fields inherited from interface org.springframework.context.SmartLifecycle

    DEFAULT_PHASE
  • Constructor Summary

    Constructors 
    Constructor Description
    ServerRSocketConnector​(io.rsocket.transport.ServerTransport<io.rsocket.transport.netty.server.CloseableChannel> serverTransport)
    Instantiate a server connector based on the provided ServerTransport.
    ServerRSocketConnector​(java.lang.String bindAddress, int port)
    Instantiate a server connector based on the TcpServerTransport.
    ServerRSocketConnector​(ServerRSocketMessageHandler serverRSocketMessageHandler)
    Instantiate a server connector based on a provided ServerRSocketMessageHandler with an assumption that RSocket server is created externally as well.
    ServerRSocketConnector​(reactor.netty.http.server.HttpServer server)
    Instantiate a server connector based on the WebsocketServerTransport.
  • Method Summary

    Modifier and Type Method Description
    void afterPropertiesSet()  
    void afterSingletonsInstantiated()  
    void destroy()  
    protected void doStart()  
    reactor.core.publisher.Mono<java.lang.Integer> getBoundPort()
    Return the port this internal server is bound or empty Mono.
    org.springframework.messaging.rsocket.RSocketRequester getClientRSocketRequester​(java.lang.Object key)
    Return connected RSocketRequester mapped by key or null.
    java.util.Map<java.lang.Object,​org.springframework.messaging.rsocket.RSocketRequester> getClientRSocketRequesters()
    Return connected RSocketRequesters mapped by keys.
    void setApplicationContext​(org.springframework.context.ApplicationContext applicationContext)  
    void setApplicationEventPublisher​(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)  
    void setClientRSocketKeyStrategy​(java.util.function.BiFunction<java.util.Map<java.lang.String,​java.lang.Object>,​org.springframework.core.io.buffer.DataBuffer,​java.lang.Object> clientRSocketKeyStrategy)
    Configure a strategy to determine a key for the client RSocketRequester connected.
    void setDataMimeType​(org.springframework.util.MimeType dataMimeType)
    Configure a MimeType for data exchanging.
    void setMetadataMimeType​(org.springframework.util.MimeType metadataMimeType)
    Configure a MimeType for metadata exchanging.
    void setRSocketStrategies​(org.springframework.messaging.rsocket.RSocketStrategies rsocketStrategies)
    Configure a RSocketStrategies for data encoding/decoding.
    void setServerConfigurer​(java.util.function.Consumer<io.rsocket.core.RSocketServer> serverConfigurer)
    Provide a Consumer to configure the RSocketServer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.context.SmartLifecycle

    getPhase, stop
  • Constructor Details

    • ServerRSocketConnector

      public ServerRSocketConnector​(ServerRSocketMessageHandler serverRSocketMessageHandler)
      Instantiate a server connector based on a provided ServerRSocketMessageHandler with an assumption that RSocket server is created externally as well. All other options are ignored in favor of provided ServerRSocketMessageHandler and its external RSocket server configuration.
      Parameters:
      serverRSocketMessageHandler - the ServerRSocketMessageHandler to rely on.
      Since:
      5.2.1
    • ServerRSocketConnector

      public ServerRSocketConnector​(java.lang.String bindAddress, int port)
      Instantiate a server connector based on the TcpServerTransport.
      Parameters:
      bindAddress - the local address to bind TCP server onto.
      port - the local TCP port to bind.
      See Also:
      ServerRSocketConnector(ServerTransport)
    • ServerRSocketConnector

      public ServerRSocketConnector​(reactor.netty.http.server.HttpServer server)
      Instantiate a server connector based on the WebsocketServerTransport.
      Parameters:
      server - the HttpServer to use.
      See Also:
      ServerRSocketConnector(ServerTransport)
    • ServerRSocketConnector

      public ServerRSocketConnector​(io.rsocket.transport.ServerTransport<io.rsocket.transport.netty.server.CloseableChannel> serverTransport)
      Instantiate a server connector based on the provided ServerTransport.
      Parameters:
      serverTransport - the ServerTransport to make server based on.
  • Method Details

    • setServerConfigurer

      public void setServerConfigurer​(java.util.function.Consumer<io.rsocket.core.RSocketServer> serverConfigurer)
      Provide a Consumer to configure the RSocketServer.
      Parameters:
      serverConfigurer - the Consumer to configure the RSocketServer.
      Since:
      5.2.6
    • setClientRSocketKeyStrategy

      public void setClientRSocketKeyStrategy​(java.util.function.BiFunction<java.util.Map<java.lang.String,​java.lang.Object>,​org.springframework.core.io.buffer.DataBuffer,​java.lang.Object> clientRSocketKeyStrategy)
      Configure a strategy to determine a key for the client RSocketRequester connected. Defaults to the destination to which a client is connected.
      Parameters:
      clientRSocketKeyStrategy - the BiFunction to determine a key for client RSocketRequesters.
    • setDataMimeType

      public void setDataMimeType​(@Nullable org.springframework.util.MimeType dataMimeType)
      Description copied from class: AbstractRSocketConnector
      Configure a MimeType for data exchanging.
      Overrides:
      setDataMimeType in class AbstractRSocketConnector
      Parameters:
      dataMimeType - the MimeType to use.
    • setMetadataMimeType

      public void setMetadataMimeType​(org.springframework.util.MimeType metadataMimeType)
      Description copied from class: AbstractRSocketConnector
      Configure a MimeType for metadata exchanging. Default to "message/x.rsocket.composite-metadata.v0".
      Overrides:
      setMetadataMimeType in class AbstractRSocketConnector
      Parameters:
      metadataMimeType - the MimeType to use.
    • setRSocketStrategies

      public void setRSocketStrategies​(org.springframework.messaging.rsocket.RSocketStrategies rsocketStrategies)
      Description copied from class: AbstractRSocketConnector
      Configure a RSocketStrategies for data encoding/decoding.
      Overrides:
      setRSocketStrategies in class AbstractRSocketConnector
      Parameters:
      rsocketStrategies - the RSocketStrategies to use.
    • setApplicationContext

      public void setApplicationContext​(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Overrides:
      setApplicationContext in class AbstractRSocketConnector
      Throws:
      org.springframework.beans.BeansException
    • setApplicationEventPublisher

      public void setApplicationEventPublisher​(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
      Specified by:
      setApplicationEventPublisher in interface org.springframework.context.ApplicationEventPublisherAware
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Overrides:
      afterPropertiesSet in class AbstractRSocketConnector
    • getClientRSocketRequesters

      public java.util.Map<java.lang.Object,​org.springframework.messaging.rsocket.RSocketRequester> getClientRSocketRequesters()
      Return connected RSocketRequesters mapped by keys.
      Returns:
      connected RSocketRequesters mapped by keys.
      See Also:
      ServerRSocketMessageHandler.getClientRSocketRequesters()
    • getClientRSocketRequester

      @Nullable public org.springframework.messaging.rsocket.RSocketRequester getClientRSocketRequester​(java.lang.Object key)
      Return connected RSocketRequester mapped by key or null.
      Parameters:
      key - the mapping key.
      Returns:
      the RSocketRequester or null.
      See Also:
      ServerRSocketMessageHandler.getClientRSocketRequester(Object)
    • getBoundPort

      public reactor.core.publisher.Mono<java.lang.Integer> getBoundPort()
      Return the port this internal server is bound or empty Mono.
      Returns:
      the port this internal server is bound or empty Mono if an external server is used.
    • doStart

      protected void doStart()
      Specified by:
      doStart in class AbstractRSocketConnector
    • destroy

      public void destroy()
      Specified by:
      destroy in interface org.springframework.beans.factory.DisposableBean
    • afterSingletonsInstantiated

      public void afterSingletonsInstantiated()
      Specified by:
      afterSingletonsInstantiated in interface org.springframework.beans.factory.SmartInitializingSingleton
      Overrides:
      afterSingletonsInstantiated in class AbstractRSocketConnector