public abstract class ServerConnectionHelper extends ConnectionHelper<Server>
| Parameter name | Value type | Default value | Description |
|---|---|---|---|
| useForwardedForHeader | boolean | false | Lookup the "X-Forwarded-For" header supported by popular proxies and caches and uses it to populate the Request.getClientAddresses() method result. This information is only safe for intermediary components within your local network. Other addresses could easily be changed by setting a fake header and should not be trusted for serious security checks. |
| reuseAddress | boolean | true | Enable/disable the SO_REUSEADDR socket option. See java.io.ServerSocket#reuseAddress property for additional details. |
clientSide, controller, inboundMessages, outboundMessages| Constructor and Description |
|---|
ServerConnectionHelper(Server server)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract boolean |
canHandle(Connection<Server> connection,
Response response)
Indicates if the connection can handle the given response at this point
in time.
|
protected Connection<Server> |
createConnection(SocketChannel socketChannel,
ConnectionController controller,
InetSocketAddress socketAddress)
Creates a connection associated to the given socket.
|
protected ServerConnectionController |
createController()
Creates a new controller.
|
protected abstract Request |
createRequest(Connection<Server> connection,
String methodName,
String resourceUri,
String protocol)
Creates a new request.
|
protected ServerSocketChannel |
createServerSocketChannel()
Create a server socket channel and bind it to the given address
|
protected SocketAddress |
createSocketAddress()
Creates a socket address to listen on.
|
void |
doHandleInbound(Response response)
Effectively handles an inbound message.
|
void |
doHandleOutbound(Response response)
Effectively handles an outbound message.
|
ServerConnectionController |
getController()
Returns the controller task.
|
ServerSocketChannel |
getServerSocketChannel()
Returns the server socket channel.
|
void |
handle(Request request,
Response response)
Handles a call by invoking the helped Server's
Server.handle(Request, Response) method. |
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.
|
boolean |
isReuseAddress()
Indicates if the controller thread should be a daemon (not blocking JVM
exit).
|
void |
setEphemeralPort(int localPort)
Sets the ephemeral port in the attributes map if necessary.
|
void |
setEphemeralPort(ServerSocket socket)
Sets the ephemeral port in the attributes map if necessary.
|
void |
start()
Start callback.
|
void |
stop()
Stop callback.
|
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, 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, setHelpedpublic ServerConnectionHelper(Server server)
server - The server to help.protected abstract boolean canHandle(Connection<Server> connection, Response response) throws IOException
connection - The parent connection.response - The response to handle.IOExceptionprotected Connection<Server> createConnection(SocketChannel socketChannel, ConnectionController controller, InetSocketAddress socketAddress) throws IOException
ConnectionHelpercreateConnection in class ConnectionHelper<Server>socketChannel - The underlying NIO socket channel.controller - The underlying IO controller.socketAddress - The associated IP address.IOExceptionprotected ServerConnectionController createController()
BaseHelpercreateController in class BaseHelper<Server>protected abstract Request createRequest(Connection<Server> connection, String methodName, String resourceUri, String protocol)
connection - The associated connection.methodName - The method name.resourceUri - The target resource URI.protocol - The protocol name and version.protected ServerSocketChannel createServerSocketChannel() throws IOException
IOExceptionprotected SocketAddress createSocketAddress() throws IOException
IOExceptionpublic void doHandleInbound(Response response)
BaseHelperdoHandleInbound in class BaseHelper<Server>response - The response to handle.public void doHandleOutbound(Response response)
BaseHelperdoHandleOutbound in class BaseHelper<Server>response - The response to handle.public ServerConnectionController getController()
BaseHelpergetController in class BaseHelper<Server>public ServerSocketChannel getServerSocketChannel()
public void handle(Request request, Response response)
Server.handle(Request, Response) method.handle in class RestletHelper<Server>request - The request to handle.response - The response to update.protected void handleInbound(Response response)
BaseHelperhandleInbound in class BaseHelper<Server>response - The message to handle.protected void handleOutbound(Response response)
BaseHelperhandleOutbound in class BaseHelper<Server>response - The message to handle.public boolean isControllerDaemon()
BaseHelperisControllerDaemon in class BaseHelper<Server>public boolean isProxying()
ConnectionHelperisProxying in class ConnectionHelper<Server>public boolean isReuseAddress()
public void setEphemeralPort(int localPort)
localPort - The ephemeral local port.public void setEphemeralPort(ServerSocket socket)
socket - The bound server socket.public void start()
throws Exception
RestletHelperstart in class BaseHelper<Server>Exceptionpublic void stop()
throws Exception
RestletHelperstop in class BaseHelper<Server>ExceptionCopyright © 2005–2015. All rights reserved.