Class NetworkListener
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default network host to which theHttpServerwill bind to in order to serviceHTTPrequests.static final intThe default network port to which theHttpServerwill bind to in order to serviceHTTPrequests. -
Constructor Summary
ConstructorsConstructorDescriptionNetworkListener(String name) Constructs a newNetworkListenerusing the specifiedname.NetworkListener(String name, boolean isBindToInherited) Constructs a newNetworkListenerusing the specifiedname, which, depending onisBindToInheritedwill or will not be bound to an inherited Channel.NetworkListener(String name, String host) Constructs a newNetworkListenerusing the specifiednameandhost.NetworkListener(String name, String host, int port) Constructs a newNetworkListenerusing the specifiedname,host, andport.NetworkListener(String name, String host, org.glassfish.grizzly.PortRange portRange) Constructs a newNetworkListenerusing the specifiedname,host, andport. -
Method Summary
Modifier and TypeMethodDescriptionbooleanderegisterAddOn(AddOn addon) DeregistersAddOnfrom this NetworkListener.AddOn[]Return the array of the registeredAddOns.protected org.glassfish.grizzly.utils.ArraySet<AddOn>Returns the direct addons collection, registered on the NetworkListener.Deprecated.use getCompressionConfig().getCompressibleMimeTypes()Deprecated.use getCompressionConfig().getCompressionMode().name()org.glassfish.grizzly.http.CompressionConfigReturnsCompressionConfigconfiguration.intDeprecated.use getCompressionConfig().getCompressionMinSize()org.glassfish.grizzly.filterchain.FilterChaingetHost()org.glassfish.grizzly.http.HttpCodecFilterorg.glassfish.grizzly.http.KeepAliveintGets the maximum POST body size, which can buffered in memory.intGets the maximum size of the POST body generated by an HTML form.intintintReturns the maximum number of headers allowed for a request.intReturns the maximum number of headers allowed for a response.getName()Deprecated.use getCompressionConfig().getNoCompressionUserAgents()intgetPort()org.glassfish.grizzly.PortRangeGet the HTTP request scheme, which if non-null overrides default one picked up by framework during runtime.org.glassfish.grizzly.Connectionorg.glassfish.grizzly.ssl.SSLEngineConfiguratorintorg.glassfish.grizzly.nio.transport.TCPNIOTransportintbooleanbooleanbooleanbooleanisPaused()booleanisSecure()booleanbooleanbooleanvoidpause()Pauses the listener.booleanregisterAddOn(AddOn addon) RegistersAddOnon this NetworkListener.voidresume()Resumes a paused listener.voidsetAuthPassThroughEnabled(boolean authPassthroughEnabled) voidsetBackendConfiguration(BackendConfiguration backendConfiguration) Sets the auxiliary configuration, which might be used, when Grizzly HttpServer is running behind HTTP gateway like reverse proxy or load balancer.voidsetChunkingEnabled(boolean chunkingEnabled) Enable/disable chunking of an HTTP response body if no content length has been explictly specified.voidsetCompressibleMimeTypes(String compressibleMimeTypes) Deprecated.use getCompressionConfig().setCompressibleMimeTypes(Set<String>)voidsetCompression(String compression) Deprecated.use getCompressionConfig().setCompressionMode(mode)voidsetCompressionMinSize(int compressionMinSize) Deprecated.use getCompressionConfig().setCompressionMinSize(int)voidsetDefaultErrorPageGenerator(ErrorPageGenerator defaultErrorPageGenerator) Sets the NetworkListener defaultErrorPageGenerator.voidsetDisableUploadTimeout(boolean disableUploadTimeout) voidsetMaxBufferedPostSize(int maxBufferedPostSize) Sets the maximum POST body size, which can buffered in memory.voidsetMaxFormPostSize(int maxFormPostSize) Sets the maximum size of the POST body generated by an HTML form.voidsetMaxHttpHeaderSize(int maxHttpHeaderSize) Configures the maximum header size for an HTTP request.voidsetMaxPendingBytes(int maxPendingBytes) The maximum size, in bytes, of all data waiting to be written to the associatedConnection.voidsetMaxRequestHeaders(int maxRequestHeaders) Sets the maximum number of headers allowed for a request.voidsetMaxResponseHeaders(int maxResponseHeaders) Sets the maximum number of headers allowed for a response.voidsetNoCompressionUserAgents(String noCompressionUserAgents) Deprecated.use getCompressionConfig().setNoCompressionUserAgents(Set<String>)voidsetRestrictedUserAgents(String restrictedUserAgents) voidSet the HTTP request scheme, which if non-null overrides default one picked up by framework during runtime.voidsetSecure(boolean secure) Enable or disable security for this listener.voidsetSendFileEnabled(boolean sendFileEnabled) voidsetSessionManager(SessionManager sessionManager) Sets the HTTP serverSessionManager.voidsetSSLEngineConfig(org.glassfish.grizzly.ssl.SSLEngineConfigurator sslEngineConfig) Provides customization of theSSLEngineused by this listener.voidsetTraceEnabled(boolean traceEnabled) voidsetTransactionTimeout(int transactionTimeout) Sets the time, in seconds, within which a request must complete its processing.voidsetTransport(org.glassfish.grizzly.nio.transport.TCPNIOTransport transport) This allows the developer to specify a customTCPNIOTransportimplementation to be used by this listener.voidsetUploadTimeout(int uploadTimeout) voidsetUriEncoding(String uriEncoding) org.glassfish.grizzly.GrizzlyFuture<NetworkListener>shutdown()Gracefully shuts down the listener.org.glassfish.grizzly.GrizzlyFuture<NetworkListener>voidImmediately shuts down the listener.voidstart()Starts the listener.voidstop()Deprecated.useshutdownNow()toString()
-
Field Details
-
DEFAULT_NETWORK_HOST
The default network host to which theHttpServerwill bind to in order to serviceHTTPrequests.- See Also:
-
DEFAULT_NETWORK_PORT
public static final int DEFAULT_NETWORK_PORTThe default network port to which theHttpServerwill bind to in order to serviceHTTPrequests.- See Also:
-
-
Constructor Details
-
NetworkListener
Constructs a new
NetworkListenerusing the specifiedname. The listener's host and port will default toDEFAULT_NETWORK_HOSTandDEFAULT_NETWORK_PORT.- Parameters:
name- the logical name of the listener.
-
NetworkListener
Constructs a new
NetworkListenerusing the specifiedname, which, depending onisBindToInheritedwill or will not be bound to an inherited Channel.- Parameters:
name- the logical name of the listener.isBindToInherited- if true theNetworkListenerwill be bound to an inherited Channel, otherwise defaultDEFAULT_NETWORK_HOSTandDEFAULT_NETWORK_PORTwill be used.- See Also:
-
NetworkListener
Constructs a new
NetworkListenerusing the specifiednameandhost. The listener's port will default toDEFAULT_NETWORK_PORT.- Parameters:
name- the logical name of the listener.host- the network host to which this listener will bind.
-
NetworkListener
Constructs a new
NetworkListenerusing the specifiedname,host, andport.- Parameters:
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..
-
NetworkListener
Constructs a new
NetworkListenerusing the specifiedname,host, andport.- Parameters:
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..
-
-
Method Details
-
getName
- Returns:
- the logical name of this listener.
-
getHost
- Returns:
- the network host to which this listener is configured to bind to.
-
getPort
public int getPort()- Returns:
- the network port to which this listener is configured to bind to.
If the
HttpServerhas not been started yet - the returned value may be: -1, ifPortRangewill 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. IfHttpServerhas been started - the value returned is the port the this listener is bound to.
-
getPortRange
public org.glassfish.grizzly.PortRange getPortRange()- Returns:
- the network port range to which this listener is configured to bind to.
-
getKeepAlive
public org.glassfish.grizzly.http.KeepAlive getKeepAlive()- Returns:
- the configuration for the keep-alive HTTP connections.
-
getTransport
public org.glassfish.grizzly.nio.transport.TCPNIOTransport getTransport()- Returns:
- the
TCPNIOTransportused by this listener.
-
setTransport
public void setTransport(org.glassfish.grizzly.nio.transport.TCPNIOTransport transport) This allows the developer to specify a custom
TCPNIOTransportimplementation to be used by this listener.Attempts to change the transport implementation while the listener is running will be ignored.
- Parameters:
transport- a customTCPNIOTransportimplementation.
-
getServerConnection
public org.glassfish.grizzly.Connection getServerConnection()- Returns:
- Grizzly server
Connection, that is responsible for accepting incoming client connections - Since:
- 2.3.24
-
getAddOns
Return the array of the registeredAddOns. Please note, possible array modifications wont affect theNetworkListener's addons list.- Returns:
- the array of the registered
AddOns.
-
getAddOnSet
Returns the direct addons collection, registered on the NetworkListener.- Returns:
- the direct addons collection, registered on the NetworkListener.
-
registerAddOn
RegistersAddOnon this NetworkListener. -
deregisterAddOn
DeregistersAddOnfrom this NetworkListener. -
isChunkingEnabled
public boolean isChunkingEnabled()- Returns:
trueif the HTTP response bodies should be chunked if not content length has been explicitly specified.
-
setChunkingEnabled
public void setChunkingEnabled(boolean chunkingEnabled) Enable/disable chunking of an HTTP response body if no content length has been explictly specified. Chunking is enabled by default.- Parameters:
chunkingEnabled-trueto enable chunking;falseto disable.
-
isSecure
public boolean isSecure()- Returns:
trueif this is a secure listener, otherwisefalse. Listeners are not secure by default.
-
setSecure
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.
- Parameters:
secure- iftruethis listener will be secure.
-
getScheme
Get the HTTP request scheme, which if non-null overrides default one picked up by framework during runtime.- Returns:
- the HTTP request scheme
- Since:
- 2.2.4
-
setScheme
Set the HTTP request scheme, which if non-null overrides default one picked up by framework during runtime.- Parameters:
scheme- the HTTP request scheme- Since:
- 2.2.4
-
getBackendConfiguration
- Returns:
- the auxiliary configuration, which might be used, when Grizzly HttpServer is running behind HTTP gateway like reverse proxy or load balancer.
- Since:
- 2.3.18
-
setBackendConfiguration
Sets the auxiliary configuration, which might be used, when Grizzly HttpServer is running behind HTTP gateway like reverse proxy or load balancer.- Parameters:
backendConfiguration-BackendConfiguration- Since:
- 2.3.18
-
getMaxRequestHeaders
public int getMaxRequestHeaders()Returns the maximum number of headers allowed for a request.- Since:
- 2.2.11
-
setMaxRequestHeaders
public void setMaxRequestHeaders(int maxRequestHeaders) Sets the maximum number of headers allowed for a request. If the specified value is less than zero, then there may be an unlimited number of headers (memory permitting).- Since:
- 2.2.11
-
getMaxResponseHeaders
public int getMaxResponseHeaders()Returns the maximum number of headers allowed for a response.- Since:
- 2.2.11
-
setMaxResponseHeaders
public void setMaxResponseHeaders(int maxResponseHeaders) Sets the maximum number of headers allowed for a response. If the specified value is less than zero, then there may be an unlimited number of headers (memory permitting).- Since:
- 2.2.11
-
getSslEngineConfig
public org.glassfish.grizzly.ssl.SSLEngineConfigurator getSslEngineConfig()- Returns:
- the
SSLEngineconfiguration for this listener.
-
setSSLEngineConfig
public void setSSLEngineConfig(org.glassfish.grizzly.ssl.SSLEngineConfigurator sslEngineConfig) Provides customization of the
SSLEngineused by this listener.Attempts to change this value while the listener is running will be ignored.
- Parameters:
sslEngineConfig- custom SSL configuration.
-
getMaxHttpHeaderSize
public int getMaxHttpHeaderSize()- Returns:
- the maximum header size for an HTTP request.
-
setMaxHttpHeaderSize
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.
- Parameters:
maxHttpHeaderSize- the maximum header size for an HTTP request.
-
getFilterChain
public org.glassfish.grizzly.filterchain.FilterChain getFilterChain()- Returns:
- the
FilterChainused to by theTCPNIOTransportassociated with this listener.
-
getFileCache
- Returns:
- the
FileCacheassociated with this listener.
-
getMaxPendingBytes
public int getMaxPendingBytes()- Returns:
- the maximum size, in bytes, of all data waiting to be written to the associated
Connection. If not explicitly set, the value will be -1 which effectively disables resource enforcement.
-
setMaxPendingBytes
public void setMaxPendingBytes(int maxPendingBytes) The maximum size, in bytes, of all data waiting to be written to the associatedConnection. If the value is zero or less, then no resource enforcement will take place.- Parameters:
maxPendingBytes- the maximum size, in bytes, of all data waiting to be written to the associatedConnection.
-
isPaused
public boolean isPaused()- Returns:
trueif this listener has been paused, otherwisefalse
-
isStarted
public boolean isStarted()- Returns:
trueif the listener has been started, otherwisefalse.
-
start
Starts the listener.
- Throws:
IOException- if an error occurs when attempting to start the listener.
-
shutdown
public org.glassfish.grizzly.GrizzlyFuture<NetworkListener> shutdown(long gracePeriod, TimeUnit timeUnit) -
shutdown
Gracefully shuts down the listener.
Any exceptions thrown during the shutdown process will be propagated to the returnedGrizzlyFuture.- Returns:
GrizzlyFuture
-
shutdownNow
Immediately shuts down the listener.
- Throws:
IOException- if an error occurs when attempting to shut down the listener
-
stop
Deprecated.useshutdownNow()Immediately shuts down the listener.
- Throws:
IOException- if an error occurs when attempting to shut down the listener
-
pause
public void pause()Pauses the listener.
-
resume
public void resume()Resumes a paused listener.
-
toString
-
createManagementObject
-
getHttpServerFilter
-
getHttpCodecFilter
public org.glassfish.grizzly.http.HttpCodecFilter getHttpCodecFilter() -
isAuthPassThroughEnabled
public boolean isAuthPassThroughEnabled() -
setAuthPassThroughEnabled
public void setAuthPassThroughEnabled(boolean authPassthroughEnabled) -
getCompressionConfig
public org.glassfish.grizzly.http.CompressionConfig getCompressionConfig()ReturnsCompressionConfigconfiguration.- Since:
- 2.3.5
-
getCompression
Deprecated.use getCompressionConfig().getCompressionMode().name() -
setCompression
Deprecated.use getCompressionConfig().setCompressionMode(mode) -
getCompressionMinSize
public int getCompressionMinSize()Deprecated.use getCompressionConfig().getCompressionMinSize() -
setCompressionMinSize
public void setCompressionMinSize(int compressionMinSize) Deprecated.use getCompressionConfig().setCompressionMinSize(int) -
getCompressibleMimeTypes
Deprecated.use getCompressionConfig().getCompressibleMimeTypes() -
setCompressibleMimeTypes
Deprecated.use getCompressionConfig().setCompressibleMimeTypes(Set<String>) -
getNoCompressionUserAgents
Deprecated.use getCompressionConfig().getNoCompressionUserAgents() -
setNoCompressionUserAgents
Deprecated.use getCompressionConfig().setNoCompressionUserAgents(Set<String>) -
isDisableUploadTimeout
public boolean isDisableUploadTimeout() -
setDisableUploadTimeout
public void setDisableUploadTimeout(boolean disableUploadTimeout) -
getMaxFormPostSize
public int getMaxFormPostSize()Gets the maximum size of the POST body generated by an HTML form.-1value means no size limits applied.- Since:
- 2.3
-
setMaxFormPostSize
public void setMaxFormPostSize(int maxFormPostSize) Sets the maximum size of the POST body generated by an HTML form.-1value means no size limits applied.- Since:
- 2.3
-
getMaxBufferedPostSize
public int getMaxBufferedPostSize()Gets the maximum POST body size, which can buffered in memory.-1value means no size limits applied.- Since:
- 2.3
-
setMaxBufferedPostSize
public void setMaxBufferedPostSize(int maxBufferedPostSize) Sets the maximum POST body size, which can buffered in memory.-1value means no size limits applied.- Since:
- 2.3
-
getRestrictedUserAgents
-
setRestrictedUserAgents
-
isTraceEnabled
public boolean isTraceEnabled() -
setTraceEnabled
public void setTraceEnabled(boolean traceEnabled) -
getUploadTimeout
public int getUploadTimeout() -
setUploadTimeout
public void setUploadTimeout(int uploadTimeout) -
getUriEncoding
-
setUriEncoding
-
getTransactionTimeout
public int getTransactionTimeout()- Returns:
- The timeout, in seconds, within which a request must complete its processing. If not explicitly set, no transaction timeout will be enforced.
-
setTransactionTimeout
public void setTransactionTimeout(int transactionTimeout) Sets the time, in seconds, within which a request must complete its processing. A value less than or equal to zero will disable this timeout. Note that this configuration option is only considered when the transport'sTransport.getWorkerThreadPool()thread pool is used to run aHttpHandler.- Parameters:
transactionTimeout- timeout in seconds
-
isSendFileEnabled
public boolean isSendFileEnabled()- Since:
- 2.2
- See Also:
-
setSendFileEnabled
public void setSendFileEnabled(boolean sendFileEnabled) - Since:
- 2.2
- See Also:
-
getDefaultErrorPageGenerator
- Returns:
- the NetworkListener default
ErrorPageGenerator.
-
setDefaultErrorPageGenerator
Sets the NetworkListener defaultErrorPageGenerator.- Parameters:
defaultErrorPageGenerator-
-
getSessionManager
- Returns:
- the HTTP server
SessionManager - See Also:
-
setSessionManager
Sets the HTTP serverSessionManager.- Parameters:
sessionManager-SessionManager
-