public abstract class BaseHelper<T extends Connector> extends ConnectorHelper<T>
Parameter name | Value type | Default value | Description |
---|---|---|---|
controllerDaemon | boolean | true | Indicates if the controller thread should be a daemon (not blocking JVM exit). |
controllerSleepTimeMs | int | 100 | Time for the controller thread to sleep between each control. |
inboundBufferSize | int | IoUtils.BUFFER_SIZE |
The size of the buffer when reading messages. |
minThreads | int | 1 | Minimum threads waiting to service requests. |
maxThreads | int | 10 | Maximum threads that will service requests. |
maxConnectionsPerHost | int | -1 | Maximum number of concurrent connections per host (IP address). |
maxTotalConnections | int | -1 | Maximum number of concurrent connections in total. |
outboundBufferSize | int | IoUtils.BUFFER_SIZE |
The size of the buffer when writing messages. |
persistingConnections | boolean | true | Indicates if connections should be kept alive after a call. |
pipeliningConnections | boolean | false | Indicates if pipelining connections are supported. |
threadMaxIdleTimeMs | int | 60000 | Time for an idle thread to wait for an operation before being collected. |
tracing | boolean | false | Indicates if all messages should be printed on the standard console. |
Constructor and Description |
---|
BaseHelper(T connector,
boolean clientSide)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected abstract Connection<T> |
createConnection(BaseHelper<T> helper,
java.net.Socket socket,
java.nio.channels.SocketChannel socketChannel)
Creates a connection associated to the given socket.
|
protected Controller |
createController()
Creates a new controller.
|
protected java.util.concurrent.ExecutorService |
createControllerService()
Creates the connector controller service.
|
protected Response |
createResponse(Request request)
Creates the response object.
|
protected java.util.concurrent.ThreadPoolExecutor |
createWorkerService()
Creates the handler service.
|
protected java.util.Set<Connection<T>> |
getConnections()
Returns the set of active connections.
|
Controller |
getController()
Returns the controller task.
|
int |
getControllerSleepTimeMs()
Returns the time for the controller thread to sleep between each control.
|
int |
getInboundBufferSize()
Returns the size of the buffer when reading messages..
|
protected java.util.Queue<Response> |
getInboundMessages()
Returns the queue of inbound messages pending for handling.
|
int |
getMaxConnectionsPerHost()
Returns the maximum concurrent connections per host (IP address).
|
int |
getMaxThreads()
Returns the maximum threads that will service requests.
|
int |
getMaxTotalConnections()
Returns the maximum number of concurrent connections allowed.
|
int |
getMinThreads()
Returns the minimum threads waiting to service requests.
|
int |
getOutboundBufferSize()
Returns the size of the buffer when writing messages..
|
protected java.util.Queue<Response> |
getOutboundMessages()
Returns the queue of outbound messages pending for handling.
|
int |
getThreadMaxIdleTimeMs()
Returns the time for an idle thread to wait for an operation before being
collected.
|
java.util.concurrent.ThreadPoolExecutor |
getWorkerService()
Returns the connection handler service.
|
abstract void |
handleInbound(Response response)
Handles an inbound message.
|
void |
handleNextInbound()
Handles the next inbound message.
|
protected void |
handleNextOutbound()
Handles the next outbound message.
|
abstract void |
handleOutbound(Response response)
Handles an outbound message.
|
boolean |
isClientSide()
Indicates if it is helping a client connector.
|
boolean |
isControllerDaemon()
Indicates if the controller thread should be a daemon (not blocking JVM
exit).
|
boolean |
isPersistingConnections()
Indicates if persistent connections should be used if possible.
|
boolean |
isPipeliningConnections()
Indicates if pipelining connections are supported.
|
abstract boolean |
isProxying()
Indicates if the helper is going through a client proxy or is a server
proxy.
|
boolean |
isServerSide()
Indicates if it is helping a server connector.
|
boolean |
isTracing()
Indicates if console tracing is enabled.
|
protected boolean |
isWorkerServiceFull()
Indicates if the worker service is busy.
|
void |
start()
Start callback.
|
void |
stop()
Stop callback.
|
getConnectorService, getContext, getProtocols, update
getAttributes, getHelped, getHelpedParameters, getLogger, getMetadataService, handle, setHelped
public BaseHelper(T connector, boolean clientSide)
connector
- The helped connector.clientSide
- True if it is helping a client connector.protected abstract Connection<T> createConnection(BaseHelper<T> helper, java.net.Socket socket, java.nio.channels.SocketChannel socketChannel) throws java.io.IOException
helper
- The parent helper.socket
- The underlying BIO socket.socketChannel
- The underlying NIO socket channel.java.io.IOException
protected Controller createController()
protected java.util.concurrent.ExecutorService createControllerService()
protected Response createResponse(Request request)
request
- The associated request.protected java.util.concurrent.ThreadPoolExecutor createWorkerService()
protected java.util.Set<Connection<T>> getConnections()
public Controller getController()
public int getControllerSleepTimeMs()
public int getInboundBufferSize()
protected java.util.Queue<Response> getInboundMessages()
public int getMaxConnectionsPerHost()
public int getMaxThreads()
public int getMaxTotalConnections()
public int getMinThreads()
public int getOutboundBufferSize()
protected java.util.Queue<Response> getOutboundMessages()
public int getThreadMaxIdleTimeMs()
public java.util.concurrent.ThreadPoolExecutor getWorkerService()
public abstract void handleInbound(Response response)
response
- The response to handle.public void handleNextInbound()
protected void handleNextOutbound()
public abstract void handleOutbound(Response response)
response
- The response to handle.public boolean isClientSide()
public boolean isControllerDaemon()
public boolean isPersistingConnections()
public boolean isPipeliningConnections()
public abstract boolean isProxying()
public boolean isServerSide()
public boolean isTracing()
protected boolean isWorkerServiceFull()
public void start() throws java.lang.Exception
RestletHelper
start
in class ConnectorHelper<T extends Connector>
java.lang.Exception
public void stop() throws java.lang.Exception
RestletHelper
stop
in class ConnectorHelper<T extends Connector>
java.lang.Exception
Copyright © 2005-2012. All Rights Reserved.