Package org.restlet.ext.nio
Class ServerConnectionHelper
- java.lang.Object
-
- org.restlet.engine.Helper
-
- org.restlet.engine.RestletHelper<T>
-
- org.restlet.engine.connector.ConnectorHelper<T>
-
- org.restlet.ext.nio.BaseHelper<T>
-
- org.restlet.ext.nio.ConnectionHelper<Server>
-
- org.restlet.ext.nio.ServerConnectionHelper
-
- Direct Known Subclasses:
HttpServerHelper
@Deprecated public abstract class ServerConnectionHelper extends ConnectionHelper<Server>
Deprecated.Will be removed to favor lower-level network extensions allowing more control at the Restlet API level.Base server helper based on NIO non blocking sockets. Here is the list of parameters that are supported. They should be set in the Server's context before it is started: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.
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.channels.ServerSocketChannelserverSocketChannelDeprecated.The server socket channel.-
Fields inherited from class org.restlet.ext.nio.BaseHelper
clientSide, controller, inboundMessages, outboundMessages
-
-
Constructor Summary
Constructors Constructor Description ServerConnectionHelper(Server server)Deprecated.Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected abstract booleancanHandle(Connection<Server> connection, Response response)Deprecated.Indicates if the connection can handle the given response at this point in time.Connection<Server>createConnection(java.nio.channels.SocketChannel socketChannel, ConnectionController controller, java.net.InetSocketAddress socketAddress)Deprecated.Creates a connection associated to the given socket.protected ServerConnectionControllercreateController()Deprecated.Creates a new controller.abstract RequestcreateRequest(Connection<Server> connection, java.lang.String methodName, java.lang.String resourceUri, java.lang.String protocol)Deprecated.Creates a new request.protected java.nio.channels.ServerSocketChannelcreateServerSocketChannel()Deprecated.Create a server socket channel and bind it to the given addressprotected java.net.SocketAddresscreateSocketAddress()Deprecated.Creates a socket address to listen on.voiddoHandleInbound(Response response)Deprecated.Effectively handles an inbound message.voiddoHandleOutbound(Response response)Deprecated.Effectively handles an outbound message.ServerConnectionControllergetController()Deprecated.Returns the controller task.java.nio.channels.ServerSocketChannelgetServerSocketChannel()Deprecated.Returns the server socket channel.voidhandle(Request request, Response response)Deprecated.Handles a call by invoking the helped Server'sServer.handle(Request, Response)method.protected voidhandleInbound(Response response)Deprecated.Handle the given inbound message.protected voidhandleOutbound(Response response)Deprecated.Handle the given outbound message.booleanisControllerDaemon()Deprecated.Indicates if the controller thread should be a daemon (not blocking JVM exit).booleanisProxying()Deprecated.Indicates if the helper is going through a client proxy or is a server proxy.booleanisReuseAddress()Deprecated.Indicates if the controller thread should be a daemon (not blocking JVM exit).voidsetEphemeralPort(int localPort)Deprecated.Sets the ephemeral port in the attributes map if necessary.voidsetEphemeralPort(java.net.ServerSocket socket)Deprecated.Sets the ephemeral port in the attributes map if necessary.voidstart()Deprecated.Start callback.voidstop()Deprecated.Stop callback.-
Methods inherited from class org.restlet.ext.nio.ConnectionHelper
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
-
Methods inherited from class org.restlet.ext.nio.BaseHelper
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
-
Methods inherited from class org.restlet.engine.connector.ConnectorHelper
getConnectorService, getContext, getProtocols, update
-
Methods inherited from class org.restlet.engine.RestletHelper
getAttributes, getHelped, getHelpedParameters, getLogger, getMetadataService, setHelped
-
-
-
-
Constructor Detail
-
ServerConnectionHelper
public ServerConnectionHelper(Server server)
Deprecated.Constructor.- Parameters:
server- The server to help.
-
-
Method Detail
-
canHandle
protected abstract boolean canHandle(Connection<Server> connection, Response response) throws java.io.IOException
Deprecated.Indicates if the connection can handle the given response at this point in time.- Parameters:
connection- The parent connection.response- The response to handle.- Returns:
- True if the connection can handle the given response at this point in time.
- Throws:
java.io.IOException
-
createConnection
public Connection<Server> createConnection(java.nio.channels.SocketChannel socketChannel, ConnectionController controller, java.net.InetSocketAddress socketAddress) throws java.io.IOException
Deprecated.Description copied from class:ConnectionHelperCreates a connection associated to the given socket.- Specified by:
createConnectionin classConnectionHelper<Server>- Parameters:
socketChannel- The underlying NIO socket channel.controller- The underlying IO controller.socketAddress- The associated IP address.- Returns:
- The new connection.
- Throws:
java.io.IOException
-
createController
protected ServerConnectionController createController()
Deprecated.Description copied from class:BaseHelperCreates a new controller.- Specified by:
createControllerin classBaseHelper<Server>- Returns:
- A new controller.
-
createRequest
public abstract Request createRequest(Connection<Server> connection, java.lang.String methodName, java.lang.String resourceUri, java.lang.String protocol)
Deprecated.Creates a new request.- Parameters:
connection- The associated connection.methodName- The method name.resourceUri- The target resource URI.protocol- The protocol name and version.- Returns:
- The created request.
-
createServerSocketChannel
protected java.nio.channels.ServerSocketChannel createServerSocketChannel() throws java.io.IOExceptionDeprecated.Create a server socket channel and bind it to the given address- Returns:
- Bound server socket channel.
- Throws:
java.io.IOException
-
createSocketAddress
protected java.net.SocketAddress createSocketAddress() throws java.io.IOExceptionDeprecated.Creates a socket address to listen on.- Returns:
- The created socket address.
- Throws:
java.io.IOException
-
doHandleInbound
public void doHandleInbound(Response response)
Deprecated.Description copied from class:BaseHelperEffectively handles an inbound message.- Specified by:
doHandleInboundin classBaseHelper<Server>- Parameters:
response- The response to handle.
-
doHandleOutbound
public void doHandleOutbound(Response response)
Deprecated.Description copied from class:BaseHelperEffectively handles an outbound message.- Specified by:
doHandleOutboundin classBaseHelper<Server>- Parameters:
response- The response to handle.
-
getController
public ServerConnectionController getController()
Deprecated.Description copied from class:BaseHelperReturns the controller task.- Overrides:
getControllerin classBaseHelper<Server>- Returns:
- The controller task.
-
getServerSocketChannel
public java.nio.channels.ServerSocketChannel getServerSocketChannel()
Deprecated.Returns the server socket channel.- Returns:
- The server socket channel.
-
handle
public void handle(Request request, Response response)
Deprecated.Handles a call by invoking the helped Server'sServer.handle(Request, Response)method.- Overrides:
handlein classRestletHelper<Server>- Parameters:
request- The request to handle.response- The response to update.
-
handleInbound
protected void handleInbound(Response response)
Deprecated.Description copied from class:BaseHelperHandle the given inbound message.- Specified by:
handleInboundin classBaseHelper<Server>- Parameters:
response- The message to handle.
-
handleOutbound
protected void handleOutbound(Response response)
Deprecated.Description copied from class:BaseHelperHandle the given outbound message.- Specified by:
handleOutboundin classBaseHelper<Server>- Parameters:
response- The message to handle.
-
isControllerDaemon
public boolean isControllerDaemon()
Deprecated.Description copied from class:BaseHelperIndicates if the controller thread should be a daemon (not blocking JVM exit).- Specified by:
isControllerDaemonin classBaseHelper<Server>- Returns:
- True if the controller thread should be a daemon (not blocking JVM exit).
-
isProxying
public boolean isProxying()
Deprecated.Description copied from class:ConnectionHelperIndicates if the helper is going through a client proxy or is a server proxy.- Specified by:
isProxyingin classConnectionHelper<Server>- Returns:
- True if the helper is going through a client proxy or is a server proxy.
-
isReuseAddress
public boolean isReuseAddress()
Deprecated.Indicates if the controller thread should be a daemon (not blocking JVM exit).- Returns:
- True if the controller thread should be a daemon (not blocking JVM exit).
-
setEphemeralPort
public void setEphemeralPort(int localPort)
Deprecated.Sets the ephemeral port in the attributes map if necessary.- Parameters:
localPort- The ephemeral local port.
-
setEphemeralPort
public void setEphemeralPort(java.net.ServerSocket socket)
Deprecated.Sets the ephemeral port in the attributes map if necessary.- Parameters:
socket- The bound server socket.
-
start
public void start() throws java.lang.ExceptionDeprecated.Description copied from class:RestletHelperStart callback.- Overrides:
startin classBaseHelper<Server>- Throws:
java.lang.Exception
-
stop
public void stop() throws java.lang.ExceptionDeprecated.Description copied from class:RestletHelperStop callback.- Overrides:
stopin classBaseHelper<Server>- Throws:
java.lang.Exception
-
-