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 |
---|---|
protected 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, isSocketReuseAddress
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
getConnectorService, getContext, getProtocols, update
getAttributes, getHelped, getHelpedParameters, getLogger, getMetadataService, setHelped
protected static final String CONNECTOR_LATCH
public ClientConnectionHelper(Client connector)
connector
- The helped client connector.protected Connection<Client> createConnection(SocketChannel socketChannel, ConnectionController controller, InetSocketAddress socketAddress) throws IOException
ConnectionHelper
createConnection
in class ConnectionHelper<Client>
socketChannel
- The underlying NIO socket channel.controller
- The underlying IO controller.socketAddress
- The associated IP address.IOException
protected ConnectionController createController()
BaseHelper
createController
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.UnknownHostException
IOException
protected 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.UnknownHostException
IOException
public void doHandleInbound(Response response)
BaseHelper
doHandleInbound
in class BaseHelper<Client>
response
- The response to handle.public void doHandleOutbound(Response response)
BaseHelper
doHandleOutbound
in class BaseHelper<Client>
response
- The response to handle.protected Connection<Client> getBestConnection(Request request) throws UnknownHostException, IOException
request
- The request to handle.UnknownHostException
IOException
public 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)
RestletHelper
handle
in class RestletHelper<Client>
request
- The request to handle.response
- The response to update.protected void handleInbound(Response response)
BaseHelper
handleInbound
in class BaseHelper<Client>
response
- The message to handle.protected void handleOutbound(Response response)
BaseHelper
handleOutbound
in class BaseHelper<Client>
response
- The message to handle.public boolean isControllerDaemon()
BaseHelper
isControllerDaemon
in class BaseHelper<Client>
public boolean isProxying()
ConnectionHelper
isProxying
in class ConnectionHelper<Client>
public void start() throws Exception
RestletHelper
start
in class BaseHelper<Client>
Exception
public void stop() throws Exception
RestletHelper
stop
in class BaseHelper<Client>
Exception
protected void unblock(Response response)
response
- The response.Copyright © 2005–2013. All rights reserved.