Class ServerConnectionHelper

  • Direct Known Subclasses:
    HttpServerHelper

    @Deprecated
    public abstract class ServerConnectionHelper
    extends ConnectionHelper<Server>
    Deprecated.
    Will be removed to favor lower-level network extensions allowing more control at the Restlet API level.
    Base server helper based on NIO non blocking sockets. Here is the list of parameters that are supported. They should be set in the Server's context before it is started:
    Parameter name Value type Default value Description
    useForwardedForHeader boolean false Lookup the "X-Forwarded-For" header supported by popular proxies and caches and uses it to populate the Request.getClientAddresses() method result. This information is only safe for intermediary components within your local network. Other addresses could easily be changed by setting a fake header and should not be trusted for serious security checks.
    reuseAddress boolean true Enable/disable the SO_REUSEADDR socket option. See java.io.ServerSocket#reuseAddress property for additional details.
    • Field Detail

      • serverSocketChannel

        private volatile java.nio.channels.ServerSocketChannel serverSocketChannel
        Deprecated.
        The server socket channel.
    • Constructor Detail

      • ServerConnectionHelper

        public ServerConnectionHelper​(Server server)
        Deprecated.
        Constructor.
        Parameters:
        server - The server to help.
    • Method Detail

      • canHandle

        protected abstract boolean canHandle​(Connection<Server> connection,
                                             Response response)
                                      throws java.io.IOException
        Deprecated.
        Indicates if the connection can handle the given response at this point in time.
        Parameters:
        connection - The parent connection.
        response - The response to handle.
        Returns:
        True if the connection can handle the given response at this point in time.
        Throws:
        java.io.IOException
      • createConnection

        public Connection<Server> createConnection​(java.nio.channels.SocketChannel socketChannel,
                                                   ConnectionController controller,
                                                   java.net.InetSocketAddress socketAddress)
                                            throws java.io.IOException
        Deprecated.
        Description copied from class: ConnectionHelper
        Creates a connection associated to the given socket.
        Specified by:
        createConnection in class ConnectionHelper<Server>
        Parameters:
        socketChannel - The underlying NIO socket channel.
        controller - The underlying IO controller.
        socketAddress - The associated IP address.
        Returns:
        The new connection.
        Throws:
        java.io.IOException
      • createRequest

        public abstract Request createRequest​(Connection<Server> connection,
                                              java.lang.String methodName,
                                              java.lang.String resourceUri,
                                              java.lang.String protocol)
        Deprecated.
        Creates a new request.
        Parameters:
        connection - The associated connection.
        methodName - The method name.
        resourceUri - The target resource URI.
        protocol - The protocol name and version.
        Returns:
        The created request.
      • createServerSocketChannel

        protected java.nio.channels.ServerSocketChannel createServerSocketChannel()
                                                                           throws java.io.IOException
        Deprecated.
        Create a server socket channel and bind it to the given address
        Returns:
        Bound server socket channel.
        Throws:
        java.io.IOException
      • createSocketAddress

        protected java.net.SocketAddress createSocketAddress()
                                                      throws java.io.IOException
        Deprecated.
        Creates a socket address to listen on.
        Returns:
        The created socket address.
        Throws:
        java.io.IOException
      • doHandleInbound

        public void doHandleInbound​(Response response)
        Deprecated.
        Description copied from class: BaseHelper
        Effectively handles an inbound message.
        Specified by:
        doHandleInbound in class BaseHelper<Server>
        Parameters:
        response - The response to handle.
      • doHandleOutbound

        public void doHandleOutbound​(Response response)
        Deprecated.
        Description copied from class: BaseHelper
        Effectively handles an outbound message.
        Specified by:
        doHandleOutbound in class BaseHelper<Server>
        Parameters:
        response - The response to handle.
      • getServerSocketChannel

        public java.nio.channels.ServerSocketChannel getServerSocketChannel()
        Deprecated.
        Returns the server socket channel.
        Returns:
        The server socket channel.
      • handleInbound

        protected void handleInbound​(Response response)
        Deprecated.
        Description copied from class: BaseHelper
        Handle the given inbound message.
        Specified by:
        handleInbound in class BaseHelper<Server>
        Parameters:
        response - The message to handle.
      • handleOutbound

        protected void handleOutbound​(Response response)
        Deprecated.
        Description copied from class: BaseHelper
        Handle the given outbound message.
        Specified by:
        handleOutbound in class BaseHelper<Server>
        Parameters:
        response - The message to handle.
      • isControllerDaemon

        public boolean isControllerDaemon()
        Deprecated.
        Description copied from class: BaseHelper
        Indicates if the controller thread should be a daemon (not blocking JVM exit).
        Specified by:
        isControllerDaemon in class BaseHelper<Server>
        Returns:
        True if the controller thread should be a daemon (not blocking JVM exit).
      • isProxying

        public boolean isProxying()
        Deprecated.
        Description copied from class: ConnectionHelper
        Indicates if the helper is going through a client proxy or is a server proxy.
        Specified by:
        isProxying in class ConnectionHelper<Server>
        Returns:
        True if the helper is going through a client proxy or is a server proxy.
      • isReuseAddress

        public boolean isReuseAddress()
        Deprecated.
        Indicates if the controller thread should be a daemon (not blocking JVM exit).
        Returns:
        True if the controller thread should be a daemon (not blocking JVM exit).
      • setEphemeralPort

        public void setEphemeralPort​(int localPort)
        Deprecated.
        Sets the ephemeral port in the attributes map if necessary.
        Parameters:
        localPort - The ephemeral local port.
      • setEphemeralPort

        public void setEphemeralPort​(java.net.ServerSocket socket)
        Deprecated.
        Sets the ephemeral port in the attributes map if necessary.
        Parameters:
        socket - The bound server socket.
      • start

        public void start()
                   throws java.lang.Exception
        Deprecated.
        Description copied from class: RestletHelper
        Start callback.
        Overrides:
        start in class BaseHelper<Server>
        Throws:
        java.lang.Exception
      • stop

        public void stop()
                  throws java.lang.Exception
        Deprecated.
        Description copied from class: RestletHelper
        Stop callback.
        Overrides:
        stop in class BaseHelper<Server>
        Throws:
        java.lang.Exception