Class NetworkListener

java.lang.Object
org.glassfish.grizzly.http.server.NetworkListener

public class NetworkListener extends Object
  • Field Details

    • DEFAULT_NETWORK_HOST

      public static final String DEFAULT_NETWORK_HOST
      The default network host to which the HttpServer will bind to in order to service HTTP requests.
      See Also:
    • DEFAULT_NETWORK_PORT

      public static final int DEFAULT_NETWORK_PORT
      The default network port to which the HttpServer will bind to in order to service HTTP requests.
      See Also:
  • Constructor Details

    • NetworkListener

      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.

      Parameters:
      name - the logical name of the listener.
    • NetworkListener

      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.

      Parameters:
      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.
      See Also:
    • NetworkListener

      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.

      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 NetworkListener using the specified name, host, and port.

      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 NetworkListener using the specified name, host, and port.

      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

      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 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.
    • 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 TCPNIOTransport used by this listener.
    • setTransport

      public void setTransport(org.glassfish.grizzly.nio.transport.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.

      Parameters:
      transport - a custom TCPNIOTransport implementation.
    • 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 registered AddOns. Please note, possible array modifications wont affect the NetworkListener'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.
    • registerAddOn

      public boolean registerAddOn(AddOn addon)
      Registers AddOn on this NetworkListener.
      Parameters:
      addon - the AddOn to be registered.
      Returns:
      true, if the AddOn wasn't registered before, otherwise the existing AddOn will be replaced and this method returns false.
    • deregisterAddOn

      public boolean deregisterAddOn(AddOn addon)
      Deregisters AddOn from this NetworkListener.
      Parameters:
      addon - the AddOn to deregister.
      Returns:
      true, if the AddOn was successfully removed, or false the the AddOn wasn't registered on the NetworkListener.
    • isChunkingEnabled

      public boolean isChunkingEnabled()
      Returns:
      true if 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 - true to enable chunking; false to disable.
    • isSecure

      public boolean isSecure()
      Returns:
      true if this is a secure listener, otherwise false. 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 - if true this 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 SSLEngine configuration for this listener.
    • setSSLEngineConfig

      public void setSSLEngineConfig(org.glassfish.grizzly.ssl.SSLEngineConfigurator sslEngineConfig)

      Provides customization of the SSLEngine used 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 FilterChain used to by the TCPNIOTransport associated with this listener.
    • getFileCache

      public FileCache getFileCache()
      Returns:
      the FileCache associated 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 associated Connection. 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 associated Connection.
    • isPaused

      public boolean isPaused()
      Returns:
      true if this listener has been paused, otherwise false
    • isStarted

      public boolean isStarted()
      Returns:
      true if the listener has been started, otherwise false.
    • start

      public void start() throws IOException

      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

      public org.glassfish.grizzly.GrizzlyFuture<NetworkListener> shutdown()

      Gracefully shuts down the listener.

      Any exceptions thrown during the shutdown process will be propagated to the returned GrizzlyFuture.
      Returns:
      GrizzlyFuture
    • shutdownNow

      public void shutdownNow() throws IOException

      Immediately shuts down the listener.

      Throws:
      IOException - if an error occurs when attempting to shut down the listener
    • stop

      public void stop() throws IOException
      Deprecated.

      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()
      Overrides:
      toString in class Object
      Returns:
      a value containing the name, host, port, and secure status of this listener.
    • 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()
      Returns CompressionConfig configuration.
      Since:
      2.3.5
    • getCompression

      public String getCompression()
      Deprecated.
      use getCompressionConfig().getCompressionMode().name()
    • setCompression

      public void setCompression(String compression)
      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

      public String getCompressibleMimeTypes()
      Deprecated.
      use getCompressionConfig().getCompressibleMimeTypes()
    • setCompressibleMimeTypes

      public void setCompressibleMimeTypes(String compressibleMimeTypes)
      Deprecated.
      use getCompressionConfig().setCompressibleMimeTypes(Set<String>)
    • getNoCompressionUserAgents

      public String getNoCompressionUserAgents()
      Deprecated.
      use getCompressionConfig().getNoCompressionUserAgents()
    • setNoCompressionUserAgents

      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. -1 value 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. -1 value means no size limits applied.
      Since:
      2.3
    • getMaxBufferedPostSize

      public int getMaxBufferedPostSize()
      Gets the maximum POST body size, which can buffered in memory. -1 value 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. -1 value 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's Transport.getWorkerThreadPool() thread pool is used to run a HttpHandler.
      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

      public ErrorPageGenerator getDefaultErrorPageGenerator()
      Returns:
      the NetworkListener default ErrorPageGenerator.
    • setDefaultErrorPageGenerator

      public void setDefaultErrorPageGenerator(ErrorPageGenerator defaultErrorPageGenerator)
      Sets the NetworkListener default ErrorPageGenerator.
      Parameters:
      defaultErrorPageGenerator -
    • getSessionManager

      public SessionManager getSessionManager()
      Returns:
      the HTTP server SessionManager
      See Also:
    • setSessionManager

      public void setSessionManager(SessionManager sessionManager)
      Sets the HTTP server SessionManager.
      Parameters:
      sessionManager - SessionManager