Class NetworkListener
- java.lang.Object
-
- org.glassfish.grizzly.http.server.NetworkListener
-
public class NetworkListener extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_NETWORK_HOSTThe default network host to which theHttpServerwill bind to in order to serviceHTTPrequests.static intDEFAULT_NETWORK_PORTThe default network port to which theHttpServerwill bind to in order to serviceHTTPrequests.
-
Constructor Summary
Constructors Constructor Description NetworkListener(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.NetworkListener(String name, String host, org.glassfish.grizzly.PortRange portRange, boolean randomStartPort)Constructs a newNetworkListenerusing the specifiedname,host, andport.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ObjectcreateManagementObject()booleanderegisterAddOn(AddOn addon)DeregistersAddOnfrom this NetworkListener.AddOn[]getAddOns()Return the array of the registeredAddOns.protected org.glassfish.grizzly.utils.ArraySet<AddOn>getAddOnSet()Returns the direct addons collection, registered on the NetworkListener.BackendConfigurationgetBackendConfiguration()StringgetCompressibleMimeTypes()Deprecated.use getCompressionConfig().getCompressibleMimeTypes()StringgetCompression()Deprecated.use getCompressionConfig().getCompressionMode().name()org.glassfish.grizzly.http.CompressionConfiggetCompressionConfig()ReturnsCompressionConfigconfiguration.intgetCompressionMinSize()Deprecated.use getCompressionConfig().getCompressionMinSize()ErrorPageGeneratorgetDefaultErrorPageGenerator()FileCachegetFileCache()org.glassfish.grizzly.filterchain.FilterChaingetFilterChain()StringgetHost()org.glassfish.grizzly.http.HttpCodecFiltergetHttpCodecFilter()HttpServerFiltergetHttpServerFilter()org.glassfish.grizzly.http.KeepAlivegetKeepAlive()intgetMaxBufferedPostSize()Gets the maximum POST body size, which can buffered in memory.intgetMaxFormPostSize()Gets the maximum size of the POST body generated by an HTML form.intgetMaxHttpHeaderSize()intgetMaxPendingBytes()intgetMaxRequestHeaders()Returns the maximum number of headers allowed for a request.intgetMaxResponseHeaders()Returns the maximum number of headers allowed for a response.StringgetName()StringgetNoCompressionUserAgents()Deprecated.use getCompressionConfig().getNoCompressionUserAgents()intgetPort()org.glassfish.grizzly.PortRangegetPortRange()StringgetRestrictedUserAgents()StringgetScheme()Get the HTTP request scheme, which if non-null overrides default one picked up by framework during runtime.org.glassfish.grizzly.Connection<?>getServerConnection()SessionManagergetSessionManager()org.glassfish.grizzly.ssl.SSLEngineConfiguratorgetSslEngineConfig()intgetTransactionTimeout()org.glassfish.grizzly.nio.transport.TCPNIOTransportgetTransport()intgetUploadTimeout()StringgetUriEncoding()booleanisAuthPassThroughEnabled()booleanisChunkingEnabled()booleanisDisableUploadTimeout()booleanisPaused()booleanisSecure()booleanisSendFileEnabled()booleanisStarted()booleanisTraceEnabled()voidpause()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)voidsetScheme(String scheme)Set 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>shutdown(long gracePeriod, TimeUnit timeUnit)voidshutdownNow()Immediately shuts down the listener.voidstart()Starts the listener.voidstop()Deprecated.useshutdownNow()StringtoString()
-
-
-
Field Detail
-
DEFAULT_NETWORK_HOST
public static final String DEFAULT_NETWORK_HOST
The default network host to which theHttpServerwill bind to in order to serviceHTTPrequests.- See Also:
- Constant Field Values
-
DEFAULT_NETWORK_PORT
public static final int DEFAULT_NETWORK_PORT
The default network port to which theHttpServerwill bind to in order to serviceHTTPrequests.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NetworkListener
public NetworkListener(String name)
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
public NetworkListener(String name, boolean isBindToInherited)
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:
System.inheritedChannel()
-
NetworkListener
public NetworkListener(String name, String host)
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
public NetworkListener(String name, String host, int port)
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
public NetworkListener(String name, String host, org.glassfish.grizzly.PortRange portRange)
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..
-
NetworkListener
public NetworkListener(String name, String host, org.glassfish.grizzly.PortRange portRange, boolean randomStartPort)
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.randomStartPort- whether to pick a random port in the range initially.
-
-
Method Detail
-
getName
public String getName()
- Returns:
- the logical name of this listener.
-
getHost
public String 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
public AddOn[] 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
protected org.glassfish.grizzly.utils.ArraySet<AddOn> getAddOnSet()
Returns the direct addons collection, registered on the NetworkListener.- Returns:
- the direct addons collection, registered on the NetworkListener.
-
deregisterAddOn
public boolean deregisterAddOn(AddOn addon)
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
public String 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
public void setScheme(String scheme)
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
public BackendConfiguration 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
public void setBackendConfiguration(BackendConfiguration backendConfiguration)
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.
-
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
public void start() throws IOExceptionStarts 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
public org.glassfish.grizzly.GrizzlyFuture<NetworkListener> shutdown()
Gracefully shuts down the listener.
Any exceptions thrown during the shutdown process will be propagated to the returnedGrizzlyFuture.- Returns:
GrizzlyFuture
-
shutdownNow
public void shutdownNow() throws IOExceptionImmediately shuts down the listener.
- Throws:
IOException- if an error occurs when attempting to shut down the listener
-
stop
@Deprecated public void stop() throws IOException
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
public String toString()
-
createManagementObject
public Object createManagementObject()
-
getHttpServerFilter
public HttpServerFilter 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 public String getCompression()
Deprecated.use getCompressionConfig().getCompressionMode().name()
-
setCompression
@Deprecated public void setCompression(String compression)
Deprecated.use getCompressionConfig().setCompressionMode(mode)
-
getCompressionMinSize
@Deprecated public int getCompressionMinSize()
Deprecated.use getCompressionConfig().getCompressionMinSize()
-
setCompressionMinSize
@Deprecated public void setCompressionMinSize(int compressionMinSize)
Deprecated.use getCompressionConfig().setCompressionMinSize(int)
-
getCompressibleMimeTypes
@Deprecated public String getCompressibleMimeTypes()
Deprecated.use getCompressionConfig().getCompressibleMimeTypes()
-
setCompressibleMimeTypes
@Deprecated public void setCompressibleMimeTypes(String compressibleMimeTypes)
Deprecated.use getCompressionConfig().setCompressibleMimeTypes(Set<String>)
-
getNoCompressionUserAgents
@Deprecated public String getNoCompressionUserAgents()
Deprecated.use getCompressionConfig().getNoCompressionUserAgents()
-
setNoCompressionUserAgents
@Deprecated public void setNoCompressionUserAgents(String noCompressionUserAgents)
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
public String getRestrictedUserAgents()
-
setRestrictedUserAgents
public void setRestrictedUserAgents(String restrictedUserAgents)
-
isTraceEnabled
public boolean isTraceEnabled()
-
setTraceEnabled
public void setTraceEnabled(boolean traceEnabled)
-
getUploadTimeout
public int getUploadTimeout()
-
setUploadTimeout
public void setUploadTimeout(int uploadTimeout)
-
getUriEncoding
public String getUriEncoding()
-
setUriEncoding
public void setUriEncoding(String uriEncoding)
-
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:
ServerFilterConfiguration.isSendFileEnabled()
-
setSendFileEnabled
public void setSendFileEnabled(boolean sendFileEnabled)
- Since:
- 2.2
- See Also:
ServerFilterConfiguration.setSendFileEnabled(boolean)
-
getDefaultErrorPageGenerator
public ErrorPageGenerator getDefaultErrorPageGenerator()
- Returns:
- the NetworkListener default
ErrorPageGenerator.
-
setDefaultErrorPageGenerator
public void setDefaultErrorPageGenerator(ErrorPageGenerator defaultErrorPageGenerator)
Sets the NetworkListener defaultErrorPageGenerator.- Parameters:
defaultErrorPageGenerator-
-
getSessionManager
public SessionManager getSessionManager()
- Returns:
- the HTTP server
SessionManager - See Also:
setSessionManager(org.glassfish.grizzly.http.server.SessionManager)
-
setSessionManager
public void setSessionManager(SessionManager sessionManager)
Sets the HTTP serverSessionManager.- Parameters:
sessionManager-SessionManager
-
-