public class NetworkListener extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_NETWORK_HOST
The default network host to which the
HttpServer will bind to in order to service HTTP
requests. |
static int |
DEFAULT_NETWORK_PORT
The default network port to which the
HttpServer will bind to in order to service HTTP
requests. |
Constructor and Description |
---|
NetworkListener(String name)
Constructs a new
NetworkListener using the specified name . |
NetworkListener(String name,
boolean isBindToInherited)
Constructs a new
NetworkListener using the specified name , which,
depending on isBindToInherited will or will not be bound to an inherited Channel. |
NetworkListener(String name,
String host)
Constructs a new
NetworkListener using the specified name and host . |
NetworkListener(String name,
String host,
int port)
Constructs a new
NetworkListener using the specified name , host , and
port . |
NetworkListener(String name,
String host,
PortRange portRange)
Constructs a new
NetworkListener using the specified name , host , and
port . |
Modifier and Type | Method and Description |
---|---|
Object |
createManagementObject() |
boolean |
deregisterAddOn(AddOn addon)
Deregisters
AddOn from this NetworkListener. |
AddOn[] |
getAddOns()
Return the array of the registered
AddOn s. |
protected ArraySet<AddOn> |
getAddOnSet()
Returns the direct addons collection, registered on the NetworkListener.
|
String |
getCompressibleMimeTypes()
Deprecated.
use getCompressionConfig().getCompressableMimeTypes()
|
String |
getCompression()
Deprecated.
use getCompressionConfig().getCompressionMode().name()
|
CompressionConfig |
getCompressionConfig()
Returns
CompressionConfig configuration. |
int |
getCompressionMinSize()
Deprecated.
use getCompressionConfig().getCompressionMinSize()
|
ErrorPageGenerator |
getDefaultErrorPageGenerator()
Returns the NetworkListener default
ErrorPageGenerator . |
FileCache |
getFileCache() |
FilterChain |
getFilterChain() |
String |
getHost() |
HttpCodecFilter |
getHttpCodecFilter() |
HttpServerFilter |
getHttpServerFilter() |
KeepAlive |
getKeepAlive() |
int |
getMaxBufferedPostSize()
Gets the maximum POST body size, which can buffered in memory.
|
int |
getMaxFormPostSize()
Gets the maximum size of the POST body generated by an HTML form.
|
int |
getMaxHttpHeaderSize() |
int |
getMaxPendingBytes() |
int |
getMaxRequestHeaders()
Returns the maximum number of headers allowed for a request.
|
int |
getMaxResponseHeaders()
Returns the maximum number of headers allowed for a response.
|
String |
getName() |
String |
getNoCompressionUserAgents()
Deprecated.
use getCompressionConfig().getNoCompressionUserAgents()
|
int |
getPort() |
PortRange |
getPortRange() |
String |
getRestrictedUserAgents() |
String |
getScheme()
Get the HTTP request scheme, which if non-null overrides default one
picked up by framework during runtime.
|
SSLEngineConfigurator |
getSslEngineConfig() |
int |
getTransactionTimeout() |
TCPNIOTransport |
getTransport() |
int |
getUploadTimeout() |
String |
getUriEncoding() |
boolean |
isAuthPassThroughEnabled() |
boolean |
isChunkingEnabled() |
boolean |
isDisableUploadTimeout() |
boolean |
isPaused() |
boolean |
isSecure() |
boolean |
isSendFileEnabled() |
boolean |
isStarted() |
boolean |
isTraceEnabled() |
void |
pause()
Pauses the listener.
|
boolean |
registerAddOn(AddOn addon)
Registers
AddOn on this NetworkListener. |
void |
resume()
Resumes a paused listener.
|
void |
setAuthPassThroughEnabled(boolean authPassthroughEnabled) |
void |
setChunkingEnabled(boolean chunkingEnabled)
Enable/disable chunking of an HTTP response body if no content length has been explictly specified.
|
void |
setCompressibleMimeTypes(String compressibleMimeTypes)
Deprecated.
use getCompressionConfig().setCompressableMimeTypes(Set<String>)
|
void |
setCompression(String compression)
Deprecated.
use getCompressionConfig().setCompressionMode(mode)
|
void |
setCompressionMinSize(int compressionMinSize)
Deprecated.
use getCompressionConfig().setCompressionMinSize(int)
|
void |
setDefaultErrorPageGenerator(ErrorPageGenerator defaultErrorPageGenerator)
Sets the NetworkListener default
ErrorPageGenerator . |
void |
setDisableUploadTimeout(boolean disableUploadTimeout) |
void |
setMaxBufferedPostSize(int maxBufferedPostSize)
Sets the maximum POST body size, which can buffered in memory.
|
void |
setMaxFormPostSize(int maxFormPostSize)
Sets the maximum size of the POST body generated by an HTML form.
|
void |
setMaxHttpHeaderSize(int maxHttpHeaderSize)
Configures the maximum header size for an HTTP request.
|
void |
setMaxPendingBytes(int maxPendingBytes)
The maximum size, in bytes, of all data waiting to be written to the associated
Connection . |
void |
setMaxRequestHeaders(int maxRequestHeaders)
Sets the maximum number of headers allowed for a request.
|
void |
setMaxResponseHeaders(int maxResponseHeaders)
Sets the maximum number of headers allowed for a response.
|
void |
setNoCompressionUserAgents(String noCompressionUserAgents)
Deprecated.
use getCompressionConfig().setNoCompressionUserAgents(Set<String>)
|
void |
setRestrictedUserAgents(String restrictedUserAgents) |
void |
setScheme(String scheme)
Set the HTTP request scheme, which if non-null overrides default one
picked up by framework during runtime.
|
void |
setSecure(boolean secure)
Enable or disable security for this listener.
|
void |
setSendFileEnabled(boolean sendFileEnabled) |
void |
setSSLEngineConfig(SSLEngineConfigurator sslEngineConfig)
Provides customization of the
SSLEngine used by this listener. |
void |
setTraceEnabled(boolean traceEnabled) |
void |
setTransactionTimeout(int transactionTimeout)
Sets the time, in seconds, within which a request must complete its
processing.
|
void |
setTransport(TCPNIOTransport transport)
This allows the developer to specify a custom
TCPNIOTransport implementation to be used by this
listener. |
void |
setUploadTimeout(int uploadTimeout) |
void |
setUriEncoding(String uriEncoding) |
GrizzlyFuture<NetworkListener> |
shutdown()
Gracefully shuts down the listener.
|
GrizzlyFuture<NetworkListener> |
shutdown(long gracePeriod,
TimeUnit timeUnit) |
void |
shutdownNow()
Immediately shuts down the listener.
|
void |
start()
Starts the listener.
|
void |
stop()
Deprecated.
use
shutdownNow() |
String |
toString() |
public static final String DEFAULT_NETWORK_HOST
HttpServer
will bind to in order to service HTTP
requests.public static final int DEFAULT_NETWORK_PORT
HttpServer
will bind to in order to service HTTP
requests.public NetworkListener(String name)
Constructs a new NetworkListener
using the specified name
. The listener's host and
port will default to DEFAULT_NETWORK_HOST
and DEFAULT_NETWORK_PORT
.
name
- the logical name of the listener.public NetworkListener(String name, boolean isBindToInherited)
Constructs a new NetworkListener
using the specified name
, which,
depending on isBindToInherited
will or will not be bound to an inherited Channel.
name
- the logical name of the listener.isBindToInherited
- if true the NetworkListener
will be
bound to an inherited Channel, otherwise default DEFAULT_NETWORK_HOST
and DEFAULT_NETWORK_PORT
will be used.System.inheritedChannel()
public NetworkListener(String name, String host)
Constructs a new NetworkListener
using the specified name
and host
.
The listener's port will default to DEFAULT_NETWORK_PORT
.
name
- the logical name of the listener.host
- the network host to which this listener will bind.public NetworkListener(String name, String host, int port)
Constructs a new NetworkListener
using the specified name
, host
, and
port
.
name
- the logical name of the listener.host
- the network host to which this listener will bind.port
- the network port to which this listener will bind..public NetworkListener(String name, String host, PortRange portRange)
Constructs a new NetworkListener
using the specified name
, host
, and
port
.
name
- the logical name of the listener.host
- the network host to which this listener will bind.portRange
- the network port range to which this listener will bind..public String getName()
public String getHost()
public int getPort()
HttpServer
has not been started yet - the returned value
may be:
-1, if PortRange
will be used to bind the listener;
0, if the port will be assigned by OS;
0 < N < 65536, the port this listener will be bound to.
If HttpServer
has been started - the value returned is the port the
this listener is bound to.public PortRange getPortRange()
public KeepAlive getKeepAlive()
public TCPNIOTransport getTransport()
TCPNIOTransport
used by this listener.public void setTransport(TCPNIOTransport transport)
This allows the developer to specify a custom TCPNIOTransport
implementation to be used by this
listener.
Attempts to change the transport implementation while the listener is running will be ignored.
transport
- a custom TCPNIOTransport
implementation.public AddOn[] getAddOns()
AddOn
s.
Please note, possible array modifications wont affect the
NetworkListener
's addons list.AddOn
s.protected ArraySet<AddOn> getAddOnSet()
public boolean deregisterAddOn(AddOn addon)
AddOn
from this NetworkListener.public boolean isChunkingEnabled()
true
if the HTTP response bodies should be chunked if not content length has been explicitly
specified.public void setChunkingEnabled(boolean chunkingEnabled)
chunkingEnabled
- true
to enable chunking; false
to disable.public boolean isSecure()
true
if this is a secure listener, otherwise false
. Listeners are not secure
by default.public void setSecure(boolean secure)
Enable or disable security for this listener.
Attempts to change this value while the listener is running will be ignored.
secure
- if true
this listener will be secure.public String getScheme()
public void setScheme(String scheme)
scheme
- the HTTP request schemepublic int getMaxRequestHeaders()
public void setMaxRequestHeaders(int maxRequestHeaders)
public int getMaxResponseHeaders()
public void setMaxResponseHeaders(int maxResponseHeaders)
public SSLEngineConfigurator getSslEngineConfig()
SSLEngine
configuration for this listener.public void setSSLEngineConfig(SSLEngineConfigurator sslEngineConfig)
Provides customization of the SSLEngine
used by this listener.
Attempts to change this value while the listener is running will be ignored.
sslEngineConfig
- custom SSL configuration.public int getMaxHttpHeaderSize()
public void setMaxHttpHeaderSize(int maxHttpHeaderSize)
Configures the maximum header size for an HTTP request.
Attempts to change this value while the listener is running will be ignored.
maxHttpHeaderSize
- the maximum header size for an HTTP request.public FilterChain getFilterChain()
FilterChain
used to by the TCPNIOTransport
associated with this listener.public int getMaxPendingBytes()
Connection
.
If not explicitly set, the value will be -1 which effectively disables
resource enforcement.public void setMaxPendingBytes(int maxPendingBytes)
Connection
.
If the value is zero or less, then no resource enforcement will take place.maxPendingBytes
- the maximum size, in bytes, of all data waiting to be written to the associated Connection
.public boolean isPaused()
true
if this listener has been paused, otherwise false
public boolean isStarted()
true
if the listener has been started, otherwise false
.public void start() throws IOException
Starts the listener.
IOException
- if an error occurs when attempting to start the listener.public GrizzlyFuture<NetworkListener> shutdown(long gracePeriod, TimeUnit timeUnit)
public GrizzlyFuture<NetworkListener> shutdown()
Gracefully shuts down the listener.
Any exceptions thrown during the shutdown process will be propagated to the returnedGrizzlyFuture
.public void shutdownNow() throws IOException
Immediately shuts down the listener.
IOException
- if an error occurs when attempting to shut down the listenerpublic void stop() throws IOException
shutdownNow()
Immediately shuts down the listener.
IOException
- if an error occurs when attempting to shut down the listenerpublic void pause()
Pauses the listener.
IOException
- if an error occurs when attempting to pause the listener.public void resume()
Resumes a paused listener.
IOException
- if an error occurs when attempting to resume the listener.public String toString()
public Object createManagementObject()
public HttpServerFilter getHttpServerFilter()
public HttpCodecFilter getHttpCodecFilter()
public boolean isAuthPassThroughEnabled()
public void setAuthPassThroughEnabled(boolean authPassthroughEnabled)
public CompressionConfig getCompressionConfig()
CompressionConfig
configuration.public String getCompression()
public void setCompression(String compression)
public int getCompressionMinSize()
public void setCompressionMinSize(int compressionMinSize)
public String getCompressibleMimeTypes()
public void setCompressibleMimeTypes(String compressibleMimeTypes)
public String getNoCompressionUserAgents()
public void setNoCompressionUserAgents(String noCompressionUserAgents)
public boolean isDisableUploadTimeout()
public void setDisableUploadTimeout(boolean disableUploadTimeout)
public int getMaxFormPostSize()
-1
value means no size limits applied.public void setMaxFormPostSize(int maxFormPostSize)
-1
value means no size limits applied.public int getMaxBufferedPostSize()
-1
value means no size limits applied.public void setMaxBufferedPostSize(int maxBufferedPostSize)
-1
value means no size limits applied.public String getRestrictedUserAgents()
public void setRestrictedUserAgents(String restrictedUserAgents)
public boolean isTraceEnabled()
public void setTraceEnabled(boolean traceEnabled)
public int getUploadTimeout()
public void setUploadTimeout(int uploadTimeout)
public String getUriEncoding()
public void setUriEncoding(String uriEncoding)
public int getTransactionTimeout()
public void setTransactionTimeout(int transactionTimeout)
Transport.getWorkerThreadPool()
thread pool is used to run a HttpHandler
.transactionTimeout
- timeout in secondspublic boolean isSendFileEnabled()
ServerFilterConfiguration.isSendFileEnabled()
public void setSendFileEnabled(boolean sendFileEnabled)
ServerFilterConfiguration.setSendFileEnabled(boolean)
public ErrorPageGenerator getDefaultErrorPageGenerator()
ErrorPageGenerator
.public void setDefaultErrorPageGenerator(ErrorPageGenerator defaultErrorPageGenerator)
ErrorPageGenerator
.defaultErrorPageGenerator
- Copyright © 2014 Oracle Corporation. All rights reserved.