Module swim.io
Package swim.io

Interface Service

  • All Known Implementing Classes:
    AbstractService, HttpSocketService, MqttSocketService

    public interface Service
    Network service listener that handles asynchronous I/O operations for a non-blocking NIO server socket channel. A Service interfaces with the underlying asynchronous networking system via a ServiceContext. The service context invokes I/O callbacks on the Service when the underlying server socket is ready to perform I/O operations permitted by the service context's FlowControl.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Socket createSocket()
      Returns a new Socket binding to handle an incoming network connection.
      void didAccept​(Socket socket)
      Lifecycle callback invoked by the service context after the underlying network listener has accepted a new socket connection.
      void didBind()
      Lifecycle callback invoked by the service context after the underlying network listener has bound to a port.
      void didFail​(Throwable error)
      Lifecycle callback invoked by the service context when the underlying network listener fails by throwing an error.
      void didUnbind()
      Lifecycle callback invoked by the service context after the underlying network listener has been unbound.
      ServiceContext serviceContext()
      Returns the network listener context to which this Service is bound; returns null if this Service is unbound.
      void setServiceContext​(ServiceContext context)
      Sets the network listener context to which this Service is bound.
    • Method Detail

      • serviceContext

        ServiceContext serviceContext()
        Returns the network listener context to which this Service is bound; returns null if this Service is unbound.
      • setServiceContext

        void setServiceContext​(ServiceContext context)
        Sets the network listener context to which this Service is bound.
      • createSocket

        Socket createSocket()
        Returns a new Socket binding to handle an incoming network connection.
      • didBind

        void didBind()
        Lifecycle callback invoked by the service context after the underlying network listener has bound to a port.
      • didAccept

        void didAccept​(Socket socket)
        Lifecycle callback invoked by the service context after the underlying network listener has accepted a new socket connection.
      • didUnbind

        void didUnbind()
        Lifecycle callback invoked by the service context after the underlying network listener has been unbound.
      • didFail

        void didFail​(Throwable error)
        Lifecycle callback invoked by the service context when the underlying network listener fails by throwing an error. The listener will automatically be closed.