|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.engine.Helper
org.restlet.engine.RestletHelper<T>
org.restlet.engine.ConnectorHelper<T>
org.restlet.engine.connector.BaseHelper<T>
org.restlet.engine.connector.ConnectionHelper<Client>
org.restlet.engine.connector.ClientConnectionHelper
public abstract class ClientConnectionHelper
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 | |
---|---|
protected static String |
CONNECTOR_LATCH
|
Fields inherited from class org.restlet.engine.connector.BaseHelper |
---|
clientSide, controller, inboundMessages, outboundMessages |
Constructor Summary | |
---|---|
ClientConnectionHelper(Client connector)
Constructor. |
Method Summary | |
---|---|
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. |
Methods inherited from class org.restlet.engine.ConnectorHelper |
---|
getConnectorService, getContext, getProtocols, update |
Methods inherited from class org.restlet.engine.RestletHelper |
---|
getAttributes, getHelped, getHelpedParameters, getLogger, getMetadataService, setHelped |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String CONNECTOR_LATCH
Constructor Detail |
---|
public ClientConnectionHelper(Client connector)
connector
- The helped client connector.Method Detail |
---|
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 request
UnknownHostException
- 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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |