org.restlet.engine.http.connector
Class BaseServerHelper

java.lang.Object
  extended by org.restlet.engine.Helper
      extended by org.restlet.engine.RestletHelper<T>
          extended by org.restlet.engine.ConnectorHelper<T>
              extended by org.restlet.engine.http.connector.BaseHelper<Server>
                  extended by org.restlet.engine.http.connector.BaseServerHelper
Direct Known Subclasses:
HttpServerHelper

public abstract class BaseServerHelper
extends BaseHelper<Server>

Base server helper based on NIO 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.

Author:
Jerome Louvel

Constructor Summary
BaseServerHelper(Server server)
          Constructor.
 
Method Summary
protected  ExecutorService createAcceptorService()
          Creates the handler service.
protected  ServerSocket createServerSocket()
          Create a server socket channel and bind it to the given address
protected  SocketAddress createSocketAddress()
          Creates a socket address to listen on.
 ServerSocket getServerSocket()
          Returns the server socket.
 void handle(Request request, Response response)
          Handles a call by invoking the helped Server's Server.handle(Request, Response) method.
 void handleInbound(Response response)
          Handles an inbound message.
 void handleOutbound(Response response)
          Handles an outbound message.
 boolean isProxying()
          Indicates if the helper is going through a client proxy or is a server proxy.
 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.
 
Methods inherited from class org.restlet.engine.http.connector.BaseHelper
createConnection, createController, createControllerService, createResponse, createWorkerService, getConnections, getController, getControllerSleepTimeMs, getInboundBufferSize, getInboundMessages, getMaxConnectionsPerHost, getMaxThreads, getMaxTotalConnections, getMinThreads, getOutboundBufferSize, getOutboundMessages, getThreadMaxIdleTimeMs, getWorkerService, handleNextInbound, handleNextOutbound, isClientSide, isControllerDaemon, isPersistingConnections, isPipeliningConnections, isServerSide, isTracing, isWorkerServiceFull
 
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
 

Constructor Detail

BaseServerHelper

public BaseServerHelper(Server server)
Constructor.

Parameters:
server - The server to help.
Method Detail

createAcceptorService

protected ExecutorService createAcceptorService()
Creates the handler service.

Returns:
The handler service.

createServerSocket

protected ServerSocket createServerSocket()
                                   throws IOException
Create a server socket channel and bind it to the given address

Returns:
Bound server socket channel.
Throws:
IOException

createSocketAddress

protected SocketAddress createSocketAddress()
                                     throws IOException
Creates a socket address to listen on.

Returns:
The created socket address.
Throws:
IOException

getServerSocket

public ServerSocket getServerSocket()
Returns the server socket.

Returns:
The server socket.

handle

public void handle(Request request,
                   Response response)
Handles a call by invoking the helped Server's Server.handle(Request, Response) method.

Overrides:
handle in class RestletHelper<Server>
Parameters:
request - The request to handle.
response - The response to update.

handleInbound

public void handleInbound(Response response)
Description copied from class: BaseHelper
Handles an inbound message.

Specified by:
handleInbound in class BaseHelper<Server>
Parameters:
response - The response to handle.

handleOutbound

public void handleOutbound(Response response)
Description copied from class: BaseHelper
Handles an outbound message.

Specified by:
handleOutbound in class BaseHelper<Server>
Parameters:
response - The response to handle.

isProxying

public boolean isProxying()
Description copied from class: BaseHelper
Indicates if the helper is going through a client proxy or is a server proxy.

Specified by:
isProxying in class BaseHelper<Server>
Returns:
True if the helper is going through a client proxy or is a server proxy.

setEphemeralPort

public void setEphemeralPort(int localPort)
Sets the ephemeral port in the attributes map if necessary.

Parameters:
localPort - The ephemeral local port.

setEphemeralPort

public void setEphemeralPort(ServerSocket socket)
Sets the ephemeral port in the attributes map if necessary.

Parameters:
socket - The bound server socket.

start

public void start()
           throws Exception
Description copied from class: RestletHelper
Start callback.

Overrides:
start in class BaseHelper<Server>
Throws:
Exception

stop

public void stop()
          throws Exception
Description copied from class: RestletHelper
Stop callback.

Overrides:
stop in class BaseHelper<Server>
Throws:
Exception


Copyright © 2005-2011 Noelios Technologies.