public abstract class ClientConnectionHelper extends ConnectionHelper<Client>
| 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. |
| Modifier and Type | Field and Description |
|---|---|
protected static String |
CONNECTOR_LATCH |
clientSide, controller, inboundMessages, outboundMessages| Constructor and Description |
|---|
ClientConnectionHelper(Client connector)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Connection<Client> |
createConnection(SocketChannel socketChannel,
ConnectionController controller,
InetSocketAddress socketAddress)
Creates a connection associated to the given socket.
|
protected ConnectionController |
createController()
Creates a new controller.
|
protected SocketChannel |
createSocketChannel(boolean secure,
InetSocketAddress socketAddress)
Creates the socket that will be used to send the request and get the
response.
|
protected SocketChannel |
createSocketChannel(boolean secure,
String hostDomain,
int hostPort)
Creates the socket channel that will be used to send the request and get
the response.
|
void |
doHandleInbound(Response response)
Effectively handles an inbound message.
|
void |
doHandleOutbound(Response response)
Effectively handles an outbound message.
|
protected Connection<Client> |
getBestConnection(Request request)
Tries to reuse an existing connection for the given request, or creates a
new one.
|
String |
getProxyHost()
Returns the host name of the HTTP proxy, if specified.
|
int |
getProxyPort()
Returns the port of the HTTP proxy, if specified, 3128 otherwise.
|
protected InetSocketAddress |
getSocketAddress(Request request)
Returns an IP socket address representing the target host domain and port
for a given request.
|
int |
getSocketConnectTimeoutMs()
Returns the socket connection timeout.
|
void |
handle(Request request,
Response response)
Handles a call.
|
protected void |
handleInbound(Response response)
Handle the given inbound message.
|
protected void |
handleOutbound(Response response)
Handle the given outbound message.
|
boolean |
isControllerDaemon()
Indicates if the controller thread should be a daemon (not blocking JVM
exit).
|
boolean |
isProxying()
Indicates if the helper is going through a client proxy or is a server
proxy.
|
void |
start()
Start callback.
|
void |
stop()
Stop callback.
|
protected void |
unblock(Response response)
Unblocks the thread that handles the given request/response pair.
|
addOutboundMessage, checkin, checkout, configure, createConnectionPool, createInboundWay, createOutboundWay, doFinishStop, doGracefulStop, getConnectionPool, getConnections, getInitialConnections, getMaxConnectionsPerHost, getMaxTotalConnections, getSocketLingerTimeMs, getSocketReceiveBufferSize, getSocketSendBufferSize, getSocketTrafficClass, isPersistingConnections, isPipeliningConnections, isPooledConnection, isSocketKeepAlive, isSocketNoDelay, isSocketOobInline, isSocketReuseAddresscontrol, 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, traceWorkerServicegetConnectorService, getContext, getProtocols, updategetAttributes, getHelped, getHelpedParameters, getLogger, getMetadataService, setHelpedprotected static final String CONNECTOR_LATCH
public ClientConnectionHelper(Client connector)
connector - The helped client connector.public Connection<Client> createConnection(SocketChannel socketChannel, ConnectionController controller, InetSocketAddress socketAddress) throws IOException
ConnectionHelpercreateConnection in class ConnectionHelper<Client>socketChannel - The underlying NIO socket channel.controller - The underlying IO controller.socketAddress - The associated IP address.IOExceptionprotected ConnectionController createController()
BaseHelpercreateController in class BaseHelper<Client>protected SocketChannel createSocketChannel(boolean secure, InetSocketAddress socketAddress) throws UnknownHostException, IOException
getBestConnection(Request)
when a new connection is to be created. By default, calls the
createSocketChannel(boolean, String, int) method.secure - Indicates if messages will be exchanged confidentially, for
example via a SSL-secured connection.socketAddress - The holder of a host/port pair.UnknownHostExceptionIOExceptionprotected SocketChannel createSocketChannel(boolean secure, String hostDomain, int hostPort) throws UnknownHostException, IOException
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.UnknownHostExceptionIOExceptionpublic void doHandleInbound(Response response)
BaseHelperdoHandleInbound in class BaseHelper<Client>response - The response to handle.public void doHandleOutbound(Response response)
BaseHelperdoHandleOutbound in class BaseHelper<Client>response - The response to handle.protected Connection<Client> getBestConnection(Request request) throws UnknownHostException, IOException
request - The request to handle.UnknownHostExceptionIOExceptionpublic String getProxyHost()
public int getProxyPort()
protected InetSocketAddress getSocketAddress(Request request) throws UnknownHostException
getBestConnection(Request) method.request - The given requestUnknownHostException - If the proxy port is invalid or the host unresolved.public int getSocketConnectTimeoutMs()
public void handle(Request request, Response response)
RestletHelperhandle in class RestletHelper<Client>request - The request to handle.response - The response to update.protected void handleInbound(Response response)
BaseHelperhandleInbound in class BaseHelper<Client>response - The message to handle.protected void handleOutbound(Response response)
BaseHelperhandleOutbound in class BaseHelper<Client>response - The message to handle.public boolean isControllerDaemon()
BaseHelperisControllerDaemon in class BaseHelper<Client>public boolean isProxying()
ConnectionHelperisProxying in class ConnectionHelper<Client>public void start()
throws Exception
RestletHelperstart in class BaseHelper<Client>Exceptionpublic void stop()
throws Exception
RestletHelperstop in class BaseHelper<Client>Exceptionprotected void unblock(Response response)
response - The response.Copyright © 2005–2016. All rights reserved.