Package org.restlet.ext.nio
Class ClientConnectionHelper
- java.lang.Object
-
- org.restlet.engine.Helper
-
- org.restlet.engine.RestletHelper<T>
-
- org.restlet.engine.connector.ConnectorHelper<T>
-
- org.restlet.ext.nio.BaseHelper<T>
-
- org.restlet.ext.nio.ConnectionHelper<Client>
-
- org.restlet.ext.nio.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 Summary
Fields Modifier and Type Field Description protected static java.lang.StringCONNECTOR_LATCHDeprecated.-
Fields inherited from class org.restlet.ext.nio.BaseHelper
clientSide, controller, inboundMessages, outboundMessages
-
-
Constructor Summary
Constructors Constructor Description ClientConnectionHelper(Client connector)Deprecated.Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Connection<Client>createConnection(java.nio.channels.SocketChannel socketChannel, ConnectionController controller, java.net.InetSocketAddress socketAddress)Deprecated.Creates a connection associated to the given socket.protected ConnectionControllercreateController()Deprecated.Creates a new controller.protected java.nio.channels.SocketChannelcreateSocketChannel(boolean secure, java.lang.String hostDomain, int hostPort)Deprecated.Creates the socket channel that will be used to send the request and get the response.protected java.nio.channels.SocketChannelcreateSocketChannel(boolean secure, java.net.InetSocketAddress socketAddress)Deprecated.Creates the socket that will be used to send the request and get the response.voiddoHandleInbound(Response response)Deprecated.Effectively handles an inbound message.voiddoHandleOutbound(Response response)Deprecated.Effectively handles an outbound message.protected Connection<Client>getBestConnection(Request request)Deprecated.Tries to reuse an existing connection for the given request, or creates a new one.java.lang.StringgetProxyHost()Deprecated.Returns the host name of the HTTP proxy, if specified.intgetProxyPort()Deprecated.Returns the port of the HTTP proxy, if specified, 3128 otherwise.protected java.net.InetSocketAddressgetSocketAddress(Request request)Deprecated.Returns an IP socket address representing the target host domain and port for a given request.intgetSocketConnectTimeoutMs()Deprecated.Returns the socket connection timeout.voidhandle(Request request, Response response)Deprecated.Handles a call.protected voidhandleInbound(Response response)Deprecated.Handle the given inbound message.protected voidhandleOutbound(Response response)Deprecated.Handle the given outbound message.booleanisControllerDaemon()Deprecated.Indicates if the controller thread should be a daemon (not blocking JVM exit).booleanisProxying()Deprecated.Indicates if the helper is going through a client proxy or is a server proxy.voidstart()Deprecated.Start callback.voidstop()Deprecated.Stop callback.protected voidunblock(Response response)Deprecated.Unblocks the thread that handles the given request/response pair.-
Methods inherited from class org.restlet.ext.nio.ConnectionHelper
addOutboundMessage, checkin, checkout, configure, createConnectionPool, createInboundWay, createOutboundWay, doFinishStop, doGracefulStop, getConnectionPool, getConnections, getInitialConnections, getMaxConnectionsPerHost, getMaxTotalConnections, getSocketLingerTimeMs, getSocketReceiveBufferSize, getSocketSendBufferSize, getSocketTrafficClass, isPersistingConnections, isPipeliningConnections, isPooledConnection, isSocketKeepAlive, isSocketNoDelay, isSocketOobInline, isSocketReuseAddress
-
Methods inherited from class org.restlet.ext.nio.BaseHelper
control, createControllerService, createRequest, createWorkerService, execute, getController, getControllerSleepTimeMs, getInboundBufferSize, getInboundMessages, getLowThreads, getMaxIoIdleTimeMs, getMaxQueued, getMaxThreadIdleTimeMs, getMaxThreads, getMinThreads, getOutboundBufferSize, getOutboundMessages, getRequest, getThrottleTimeMs, getTraceStream, getTransport, getWorkerService, handleInbound, handleOutbound, hasWorkerThreads, isClientSide, isDirectBuffers, isServerSide, isTracing, isWorkerServiceOverloaded, onInboundError, onOutboundError, traceWorkerService
-
Methods inherited from class org.restlet.engine.connector.ConnectorHelper
getConnectorService, getContext, getProtocols, update
-
Methods inherited from class org.restlet.engine.RestletHelper
getAttributes, getHelped, getHelpedParameters, getLogger, getMetadataService, setHelped
-
-
-
-
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:ConnectionHelperCreates a connection associated to the given socket.- Specified by:
createConnectionin classConnectionHelper<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
-
createController
protected ConnectionController createController()
Deprecated.Description copied from class:BaseHelperCreates a new controller.- Specified by:
createControllerin classBaseHelper<Client>- Returns:
- A new controller.
-
createSocketChannel
protected java.nio.channels.SocketChannel createSocketChannel(boolean secure, java.net.InetSocketAddress socketAddress) throws java.net.UnknownHostException, java.io.IOExceptionDeprecated.Creates the socket that will be used to send the request and get the response. This method is called bygetBestConnection(Request)when a new connection is to be created. By default, calls thecreateSocketChannel(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.UnknownHostExceptionjava.io.IOException
-
createSocketChannel
protected java.nio.channels.SocketChannel createSocketChannel(boolean secure, java.lang.String hostDomain, int hostPort) throws java.net.UnknownHostException, java.io.IOExceptionDeprecated.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.UnknownHostExceptionjava.io.IOException
-
doHandleInbound
public void doHandleInbound(Response response)
Deprecated.Description copied from class:BaseHelperEffectively handles an inbound message.- Specified by:
doHandleInboundin classBaseHelper<Client>- Parameters:
response- The response to handle.
-
doHandleOutbound
public void doHandleOutbound(Response response)
Deprecated.Description copied from class:BaseHelperEffectively handles an outbound message.- Specified by:
doHandleOutboundin classBaseHelper<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.UnknownHostExceptionjava.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 thegetBestConnection(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:RestletHelperHandles a call.- Overrides:
handlein classRestletHelper<Client>- Parameters:
request- The request to handle.response- The response to update.
-
handleInbound
protected void handleInbound(Response response)
Deprecated.Description copied from class:BaseHelperHandle the given inbound message.- Specified by:
handleInboundin classBaseHelper<Client>- Parameters:
response- The message to handle.
-
handleOutbound
protected void handleOutbound(Response response)
Deprecated.Description copied from class:BaseHelperHandle the given outbound message.- Specified by:
handleOutboundin classBaseHelper<Client>- Parameters:
response- The message to handle.
-
isControllerDaemon
public boolean isControllerDaemon()
Deprecated.Description copied from class:BaseHelperIndicates if the controller thread should be a daemon (not blocking JVM exit).- Specified by:
isControllerDaemonin classBaseHelper<Client>- Returns:
- True if the controller thread should be a daemon (not blocking JVM exit).
-
isProxying
public boolean isProxying()
Deprecated.Description copied from class:ConnectionHelperIndicates if the helper is going through a client proxy or is a server proxy.- Specified by:
isProxyingin classConnectionHelper<Client>- Returns:
- True if the helper is going through a client proxy or is a server proxy.
-
start
public void start() throws java.lang.ExceptionDeprecated.Description copied from class:RestletHelperStart callback.- Overrides:
startin classBaseHelper<Client>- Throws:
java.lang.Exception
-
stop
public void stop() throws java.lang.ExceptionDeprecated.Description copied from class:RestletHelperStop callback.- Overrides:
stopin classBaseHelper<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.
-
-