Class HttpServer
java.lang.Object
org.glassfish.grizzly.http.server.HttpServer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.glassfish.grizzly.jmxbase.GrizzlyJmxManagerprotected Object -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(NetworkListener listener) Adds the specifiedlistenerto the server instance.protected Set<org.glassfish.grizzly.http.ContentEncoding>configureCompressionEncodings(NetworkListener listener) static HttpServerstatic HttpServercreateSimpleServer(String docRoot) static HttpServercreateSimpleServer(String docRoot, int port) static HttpServercreateSimpleServer(String docRoot, String host, int port) static HttpServercreateSimpleServer(String docRoot, String host, org.glassfish.grizzly.PortRange range) static HttpServercreateSimpleServer(String docRoot, SocketAddress socketAddress) static HttpServercreateSimpleServer(String docRoot, org.glassfish.grizzly.PortRange range) protected voidprotected voidgetListener(String name) getManagementObject(boolean clear) final ServerConfigurationbooleanremoveListener(String name) Removes theNetworkListenerassociated with the specifiedname.org.glassfish.grizzly.GrizzlyFuture<HttpServer>shutdown()Gracefully shuts down theHttpServerinstance.org.glassfish.grizzly.GrizzlyFuture<HttpServer>voidImmediately shuts down theHttpServerinstance.voidstart()Starts theHttpServer.voidstop()Deprecated.
-
Field Details
-
jmxManager
protected volatile org.glassfish.grizzly.jmxbase.GrizzlyJmxManager jmxManager -
managementObject
-
-
Constructor Details
-
HttpServer
public HttpServer()
-
-
Method Details
-
getServerConfiguration
- Returns:
- the
ServerConfigurationused to configure thisHttpServerinstance
-
addListener
Adds the specified
listenerto the server instance.If the server is already running when this method is called, the listener will be started.
- Parameters:
listener- theNetworkListenerto associate with this server instance.
-
getListener
- Parameters:
name- theNetworkListenername.- Returns:
- the
NetworkListener, if any, associated with the specifiedname.
-
getListeners
- Returns:
- a
read onlyCollectionover the listeners associated with thisHttpServerinstance.
-
removeListener
Removes the
NetworkListenerassociated 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 theNetworkListenerto 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
HttpHandlerused by thisHttpServerinstance.
-
isStarted
public boolean isStarted()- Returns:
trueif thisHttpServerhas been started.
-
getManagementObject
-
shutdown
public org.glassfish.grizzly.GrizzlyFuture<HttpServer> shutdown(long gracePeriod, TimeUnit timeUnit) -
shutdown
Gracefully shuts down the
HttpServerinstance. -
shutdownNow
public void shutdownNow()Immediately shuts down the
HttpServerinstance. -
stop
public void stop()Deprecated.useshutdownNow()Immediately shuts down the
HttpServerinstance. -
createSimpleServer
- Returns:
- a
HttpServerconfigured 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 benullwhen no static pages are needed- Returns:
- a
HttpServerconfigured to listen to requests onNetworkListener.DEFAULT_NETWORK_HOST:NetworkListener.DEFAULT_NETWORK_PORT, using the specifieddocRootas the server's document root
-
createSimpleServer
- Parameters:
docRoot- the document root, can benullwhen no static pages are neededport- the network port to which this listener will bind- Returns:
- a
HttpServerconfigured to listen to requests onNetworkListener.DEFAULT_NETWORK_HOST:port, using the specifieddocRootas the server's document root
-
createSimpleServer
- Parameters:
docRoot- the document root, can benullwhen no static pages are neededrange- port range to attempt to bind to- Returns:
- a
HttpServerconfigured to listen to requests onNetworkListener.DEFAULT_NETWORK_HOST:[port-range], using the specifieddocRootas the server's document root
-
createSimpleServer
- Parameters:
docRoot- the document root, can benullwhen no static pages are neededsocketAddress- the endpoint address to which this listener will bind- Returns:
- a
HttpServerconfigured to listen to requests onsocketAddress, using the specifieddocRootas the server's document root
-
createSimpleServer
- Parameters:
docRoot- the document root, can benullwhen 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
HttpServerconfigured to listen to requests onhost:port, using the specifieddocRootas the server's document root
-
createSimpleServer
public static HttpServer createSimpleServer(String docRoot, String host, org.glassfish.grizzly.PortRange range) - Parameters:
docRoot- the document root, can benullwhen no static pages are neededhost- the network port to which this listener will bindrange- port range to attempt to bind to- Returns:
- a
HttpServerconfigured to listen to requests onhost:[port-range], using the specifieddocRootas the server's document root
-
enableJMX
protected void enableJMX() -
disableJMX
protected void disableJMX() -
configureCompressionEncodings
protected Set<org.glassfish.grizzly.http.ContentEncoding> configureCompressionEncodings(NetworkListener listener)
-
shutdownNow()