Class HttpServer
java.lang.Object
org.glassfish.grizzly.http.server.HttpServer
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(NetworkListener listener) Adds the specifiedlistener
to the server instance.protected Set<ContentEncoding>
configureCompressionEncodings
(NetworkListener listener) static HttpServer
static HttpServer
createSimpleServer
(String docRoot) static HttpServer
createSimpleServer
(String docRoot, int port) static HttpServer
createSimpleServer
(String docRoot, String host, int port) static HttpServer
createSimpleServer
(String docRoot, String host, PortRange range) static HttpServer
createSimpleServer
(String docRoot, SocketAddress socketAddress) static HttpServer
createSimpleServer
(String docRoot, PortRange range) protected void
protected void
getListener
(String name) getManagementObject
(boolean clear) final ServerConfiguration
boolean
removeListener
(String name) Removes theNetworkListener
associated with the specifiedname
.shutdown()
Gracefully shuts down theHttpServer
instance.void
Immediately shuts down theHttpServer
instance.void
start()
Starts theHttpServer
.void
stop()
Deprecated.
-
Field Details
-
jmxManager
-
managementObject
-
-
Constructor Details
-
HttpServer
public HttpServer()
-
-
Method Details
-
getServerConfiguration
- Returns:
- the
ServerConfiguration
used to configure thisHttpServer
instance
-
addListener
Adds the specified
listener
to the server instance.If the server is already running when this method is called, the listener will be started.
- Parameters:
listener
- theNetworkListener
to associate with this server instance.
-
getListener
- Parameters:
name
- theNetworkListener
name.- Returns:
- the
NetworkListener
, if any, associated with the specifiedname
.
-
getListeners
- Returns:
- a
read only
Collection
over the listeners associated with thisHttpServer
instance.
-
removeListener
Removes the
NetworkListener
associated with the specifiedname
.If the server is running when this method is invoked, the listener will be stopped before being returned.
- Parameters:
name
- the name of theNetworkListener
to remove.- Returns:
NetworkListener
, that has been removed, or null if the listener with the given name doesn't exist
-
start
Starts the
HttpServer
.- Throws:
IOException
- if an error occurs while attempting to start the server.
-
getHttpHandler
- Returns:
- the
HttpHandler
used by thisHttpServer
instance.
-
isStarted
public boolean isStarted()- Returns:
true
if thisHttpServer
has been started.
-
getManagementObject
-
shutdown
-
shutdown
Gracefully shuts down the
HttpServer
instance. -
shutdownNow
public void shutdownNow()Immediately shuts down the
HttpServer
instance. -
stop
Deprecated.useshutdownNow()
Immediately shuts down the
HttpServer
instance. -
createSimpleServer
- Returns:
- a
HttpServer
configured to listen to requests onNetworkListener.DEFAULT_NETWORK_HOST
:NetworkListener.DEFAULT_NETWORK_PORT
, using the directory in which the server was launched the server's document root
-
createSimpleServer
- Parameters:
docRoot
- the document root, can benull
when no static pages are needed- Returns:
- a
HttpServer
configured to listen to requests onNetworkListener.DEFAULT_NETWORK_HOST
:NetworkListener.DEFAULT_NETWORK_PORT
, using the specifieddocRoot
as the server's document root
-
createSimpleServer
- Parameters:
docRoot
- the document root, can benull
when no static pages are neededport
- the network port to which this listener will bind- Returns:
- a
HttpServer
configured to listen to requests onNetworkListener.DEFAULT_NETWORK_HOST
:port
, using the specifieddocRoot
as the server's document root
-
createSimpleServer
- Parameters:
docRoot
- the document root, can benull
when no static pages are neededrange
- port range to attempt to bind to- Returns:
- a
HttpServer
configured to listen to requests onNetworkListener.DEFAULT_NETWORK_HOST
:[port-range]
, using the specifieddocRoot
as the server's document root
-
createSimpleServer
- Parameters:
docRoot
- the document root, can benull
when no static pages are neededsocketAddress
- the endpoint address to which this listener will bind- Returns:
- a
HttpServer
configured to listen to requests onsocketAddress
, using the specifieddocRoot
as the server's document root
-
createSimpleServer
- Parameters:
docRoot
- the document root, can benull
when no static pages are neededhost
- the network port to which this listener will bindport
- the network port to which this listener will bind- Returns:
- a
HttpServer
configured to listen to requests onhost
:port
, using the specifieddocRoot
as the server's document root
-
createSimpleServer
- Parameters:
docRoot
- the document root, can benull
when no static pages are neededhost
- the network port to which this listener will bindrange
- port range to attempt to bind to- Returns:
- a
HttpServer
configured to listen to requests onhost
:[port-range]
, using the specifieddocRoot
as the server's document root
-
enableJMX
protected void enableJMX() -
disableJMX
protected void disableJMX() -
configureCompressionEncodings
-
shutdownNow()