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, isSocketReuseAddress
control, 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, traceWorkerService
getConnectorService, getContext, getProtocols, update
getAttributes, getHelped, getHelpedParameters, getLogger, getMetadataService, setHelped
public 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.IOException
protected Connection<Server> createConnection(SocketChannel socketChannel, ConnectionController controller, InetSocketAddress socketAddress) throws IOException
ConnectionHelper
createConnection
in class ConnectionHelper<Server>
socketChannel
- The underlying NIO socket channel.controller
- The underlying IO controller.socketAddress
- The associated IP address.IOException
protected ServerConnectionController createController()
BaseHelper
createController
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
IOException
protected SocketAddress createSocketAddress() throws IOException
IOException
public void doHandleInbound(Response response)
BaseHelper
doHandleInbound
in class BaseHelper<Server>
response
- The response to handle.public void doHandleOutbound(Response response)
BaseHelper
doHandleOutbound
in class BaseHelper<Server>
response
- The response to handle.public ServerConnectionController getController()
BaseHelper
getController
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)
BaseHelper
handleInbound
in class BaseHelper<Server>
response
- The message to handle.protected void handleOutbound(Response response)
BaseHelper
handleOutbound
in class BaseHelper<Server>
response
- The message to handle.public boolean isControllerDaemon()
BaseHelper
isControllerDaemon
in class BaseHelper<Server>
public boolean isProxying()
ConnectionHelper
isProxying
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
RestletHelper
start
in class BaseHelper<Server>
Exception
public void stop() throws Exception
RestletHelper
stop
in class BaseHelper<Server>
Exception
Copyright © 2005–2014. All rights reserved.