Package org.restlet.engine.connector
Class NetServerHelper
- java.lang.Object
-
- org.restlet.engine.Helper
-
- org.restlet.engine.RestletHelper<T>
-
- org.restlet.engine.connector.ConnectorHelper<Server>
-
- org.restlet.engine.connector.ServerHelper
-
- org.restlet.engine.adapter.HttpServerHelper
-
- org.restlet.engine.connector.NetServerHelper
-
- Direct Known Subclasses:
HttpServerHelper,HttpsServerHelper
public abstract class NetServerHelper extends HttpServerHelper
Abstract Internal web server connector based on com.sun.net.httpserver package. 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 minThreads int 1 Minimum number of worker threads waiting to service calls, even if they are idle. Technically speaking, this is a core number of threads that are pre-started. maxThreads int 10 Maximum number of worker threads that can service calls. If this number is reached then additional calls are queued if the "maxQueued" value hasn't been reached. maxQueued int 0 Maximum number of calls that can be queued if there aren't any worker thread available to service them. If the value is '0', then no queue is used and calls are rejected if no worker thread is immediately available. If the value is '-1', then an unbounded queue is used and calls are never rejected.
Note: make sure that this value is consistent withgetMinThreads()and the behavior of theThreadPoolExecutorconfigured internally.maxThreadIdleTimeMs int 300 000 Time for an idle thread to wait for an operation before being collected.
-
-
Field Summary
Fields Modifier and Type Field Description private java.net.InetSocketAddressaddressSocket this server is listening to.private booleanconfidentialIndicates if this service is acting in HTTP or HTTPS mode.
-
Constructor Summary
Constructors Constructor Description NetServerHelper(Server server)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.concurrent.ThreadPoolExecutorcreateThreadPool()Creates the handler service.protected java.net.InetSocketAddressgetAddress()Returns the socket address this server is listening to.intgetMaxQueued()Returns the maximum number of calls that can be queued if there aren't any worker thread available to service them.intgetMaxThreadIdleTimeMs()Returns the time for an idle thread to wait for an operation before being collected.intgetMaxThreads()Returns the maximum threads that will service requests.intgetMinThreads()Returns the minimum threads waiting to service requests.booleanisConfidential()Indicates if this service is acting in HTTP or HTTPS mode.protected voidsetAddress(java.net.InetSocketAddress address)Sets the socket address this server is listening to.protected voidsetConfidential(boolean confidential)Indicates if this service is acting in HTTP or HTTPS mode.voidstart()Start callback.voidstop()Stop callback.-
Methods inherited from class org.restlet.engine.adapter.HttpServerHelper
getAdapter, handle, setAdapter
-
Methods inherited from class org.restlet.engine.connector.ServerHelper
handle, setEphemeralPort, setEphemeralPort
-
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
-
NetServerHelper
public NetServerHelper(Server server)
Constructor.- Parameters:
server- The server to help.
-
-
Method Detail
-
createThreadPool
protected java.util.concurrent.ThreadPoolExecutor createThreadPool()
Creates the handler service.- Returns:
- The handler service.
-
getAddress
protected java.net.InetSocketAddress getAddress()
Returns the socket address this server is listening to.- Returns:
- The socket address this server is listening to.
-
getMaxQueued
public int getMaxQueued()
Returns the maximum number of calls that can be queued if there aren't any worker thread available to service them. If the value is '0', then no queue is used and calls are rejected if no worker thread is immediately available. If the value is '-1', then an unbounded queue is used and calls are never rejected.
Note: make sure that this value is consistent withgetMinThreads()and the behavior of theThreadPoolExecutorconfigured internally.- Returns:
- The maximum number of calls that can be queued.
-
getMaxThreadIdleTimeMs
public int getMaxThreadIdleTimeMs()
Returns the time for an idle thread to wait for an operation before being collected.- Returns:
- The time for an idle thread to wait for an operation before being collected.
-
getMaxThreads
public int getMaxThreads()
Returns the maximum threads that will service requests.- Returns:
- The maximum threads that will service requests.
-
getMinThreads
public int getMinThreads()
Returns the minimum threads waiting to service requests. Technically speaking, this is a core number of threads that are pre-started.- Returns:
- The minimum threads waiting to service requests.
-
isConfidential
public boolean isConfidential()
Indicates if this service is acting in HTTP or HTTPS mode.- Returns:
- True if this service is acting in HTTP or HTTPS mode.
-
setAddress
protected void setAddress(java.net.InetSocketAddress address)
Sets the socket address this server is listening to.- Parameters:
address- The socket address this server is listening to.
-
setConfidential
protected void setConfidential(boolean confidential)
Indicates if this service is acting in HTTP or HTTPS mode.- Parameters:
confidential- True if this service is acting in HTTP or HTTPS mode.
-
start
public void start() throws java.lang.ExceptionDescription copied from class:RestletHelperStart callback.- Overrides:
startin classConnectorHelper<Server>- Throws:
java.lang.Exception
-
stop
public void stop() throws java.lang.ExceptionDescription copied from class:RestletHelperStop callback.- Overrides:
stopin classServerHelper- Throws:
java.lang.Exception
-
-