Class ClientConnectionHelper

  • Direct Known Subclasses:
    HttpClientHelper, HttpsClientHelper

    @Deprecated
    public abstract class ClientConnectionHelper
    extends ConnectionHelper<Client>
    Deprecated.
    Will be removed to favor lower-level network extensions allowing more control at the Restlet API level.
    Base client helper based on NIO non blocking sockets. Here is the list of parameters that are supported. They should be set in the Client's context before it is started:
    Parameter name Value type Default value Description
    proxyHost String System property "http.proxyHost" The host name of the HTTP proxy.
    proxyPort int System property "http.proxyPort" The port of the HTTP proxy.
    socketConnectTimeoutMs int 0 The socket connection timeout or 0 for unlimited wait.
    • Field Detail

      • CONNECTOR_LATCH

        protected static final java.lang.String CONNECTOR_LATCH
        Deprecated.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ClientConnectionHelper

        public ClientConnectionHelper​(Client connector)
        Deprecated.
        Constructor.
        Parameters:
        connector - The helped client connector.
    • Method Detail

      • createConnection

        public Connection<Client> 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<Client>
        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
      • createSocketChannel

        protected java.nio.channels.SocketChannel createSocketChannel​(boolean secure,
                                                                      java.net.InetSocketAddress socketAddress)
                                                               throws java.net.UnknownHostException,
                                                                      java.io.IOException
        Deprecated.
        Creates the socket that will be used to send the request and get the response. This method is called by getBestConnection(Request) when a new connection is to be created. By default, calls the createSocketChannel(boolean, String, int) method.
        Parameters:
        secure - Indicates if messages will be exchanged confidentially, for example via a SSL-secured connection.
        socketAddress - The holder of a host/port pair.
        Returns:
        The created socket.
        Throws:
        java.net.UnknownHostException
        java.io.IOException
      • createSocketChannel

        protected java.nio.channels.SocketChannel createSocketChannel​(boolean secure,
                                                                      java.lang.String hostDomain,
                                                                      int hostPort)
                                                               throws java.net.UnknownHostException,
                                                                      java.io.IOException
        Deprecated.
        Creates the socket channel that will be used to send the request and get the response.
        Parameters:
        secure - Indicates if messages will be exchanged confidentially, for example via a SSL-secured connection.
        hostDomain - The target host domain name.
        hostPort - The target host port.
        Returns:
        The created socket channel.
        Throws:
        java.net.UnknownHostException
        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<Client>
        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<Client>
        Parameters:
        response - The response to handle.
      • getBestConnection

        protected Connection<Client> getBestConnection​(Request request)
                                                throws java.net.UnknownHostException,
                                                       java.io.IOException
        Deprecated.
        Tries to reuse an existing connection for the given request, or creates a new one. It may return null if the maximum number of connections per host or in general is reached.
        Parameters:
        request - The request to handle.
        Returns:
        An existing connection able to handle the request or new one.
        Throws:
        java.net.UnknownHostException
        java.io.IOException
      • getProxyHost

        public java.lang.String getProxyHost()
        Deprecated.
        Returns the host name of the HTTP proxy, if specified.
        Returns:
        the host name of the HTTP proxy, if specified.
      • getProxyPort

        public int getProxyPort()
        Deprecated.
        Returns the port of the HTTP proxy, if specified, 3128 otherwise.
        Returns:
        the port of the HTTP proxy.
      • getSocketAddress

        protected java.net.InetSocketAddress getSocketAddress​(Request request)
                                                       throws java.net.UnknownHostException
        Deprecated.
        Returns an IP socket address representing the target host domain and port for a given request. If the helper relies on a proxy, the socket represents the domain and port of the proxy host. Used by the getBestConnection(Request) method.
        Parameters:
        request - The given request
        Returns:
        The IP socket address representing the target host domain and port for a given request.
        Throws:
        java.net.UnknownHostException - If the proxy port is invalid or the host unresolved.
      • getSocketConnectTimeoutMs

        public int getSocketConnectTimeoutMs()
        Deprecated.
        Returns the socket connection timeout.
        Returns:
        The socket connection timeout.
      • handle

        public void handle​(Request request,
                           Response response)
        Deprecated.
        Description copied from class: RestletHelper
        Handles a call.
        Overrides:
        handle in class RestletHelper<Client>
        Parameters:
        request - The request to handle.
        response - The response to update.
      • handleInbound

        protected void handleInbound​(Response response)
        Deprecated.
        Description copied from class: BaseHelper
        Handle the given inbound message.
        Specified by:
        handleInbound in class BaseHelper<Client>
        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<Client>
        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<Client>
        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<Client>
        Returns:
        True if the helper is going through a client proxy or is a server proxy.
      • start

        public void start()
                   throws java.lang.Exception
        Deprecated.
        Description copied from class: RestletHelper
        Start callback.
        Overrides:
        start in class BaseHelper<Client>
        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<Client>
        Throws:
        java.lang.Exception
      • unblock

        protected void unblock​(Response response)
        Deprecated.
        Unblocks the thread that handles the given request/response pair.
        Parameters:
        response - The response.