Class HttpServer
- java.lang.Object
-
- org.glassfish.grizzly.http.server.HttpServer
-
public class HttpServer extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected org.glassfish.grizzly.jmxbase.GrizzlyJmxManagerjmxManagerprotected ObjectmanagementObject
-
Constructor Summary
Constructors Constructor Description HttpServer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddListener(NetworkListener listener)Adds the specifiedlistenerto the server instance.protected Set<org.glassfish.grizzly.http.ContentEncoding>configureCompressionEncodings(NetworkListener listener)static HttpServercreateSimpleServer()static 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 voiddisableJMX()protected voidenableJMX()HttpHandlergetHttpHandler()NetworkListenergetListener(String name)Collection<NetworkListener>getListeners()ObjectgetManagementObject(boolean clear)ServerConfigurationgetServerConfiguration()booleanisStarted()NetworkListenerremoveListener(String name)Removes theNetworkListenerassociated with the specifiedname.org.glassfish.grizzly.GrizzlyFuture<HttpServer>shutdown()Gracefully shuts down theHttpServerinstance.org.glassfish.grizzly.GrizzlyFuture<HttpServer>shutdown(long gracePeriod, TimeUnit timeUnit)voidshutdownNow()Immediately shuts down theHttpServerinstance.voidstart()Starts theHttpServer.voidstop()Deprecated.useshutdownNow()
-
-
-
Field Detail
-
jmxManager
protected volatile org.glassfish.grizzly.jmxbase.GrizzlyJmxManager jmxManager
-
managementObject
protected volatile Object managementObject
-
-
Method Detail
-
getServerConfiguration
public final ServerConfiguration getServerConfiguration()
- Returns:
- the
ServerConfigurationused to configure thisHttpServerinstance
-
addListener
public void addListener(NetworkListener listener)
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
public NetworkListener getListener(String name)
- Parameters:
name- theNetworkListenername.- Returns:
- the
NetworkListener, if any, associated with the specifiedname.
-
getListeners
public Collection<NetworkListener> getListeners()
- Returns:
- a
read onlyCollectionover the listeners associated with thisHttpServerinstance.
-
removeListener
public NetworkListener removeListener(String name)
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
public void start() throws IOExceptionStarts the
HttpServer.- Throws:
IOException- if an error occurs while attempting to start the server.
-
getHttpHandler
public HttpHandler getHttpHandler()
- Returns:
- the
HttpHandlerused by thisHttpServerinstance.
-
isStarted
public boolean isStarted()
- Returns:
trueif thisHttpServerhas been started.
-
getManagementObject
public Object getManagementObject(boolean clear)
-
shutdown
public org.glassfish.grizzly.GrizzlyFuture<HttpServer> shutdown(long gracePeriod, TimeUnit timeUnit)
-
shutdown
public org.glassfish.grizzly.GrizzlyFuture<HttpServer> shutdown()
Gracefully shuts down the
HttpServerinstance.
-
shutdownNow
public void shutdownNow()
Immediately shuts down the
HttpServerinstance.
-
stop
@Deprecated public void stop()
Deprecated.useshutdownNow()Immediately shuts down the
HttpServerinstance.
-
createSimpleServer
public static HttpServer 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
public static HttpServer createSimpleServer(String docRoot)
- 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
public static HttpServer createSimpleServer(String docRoot, int port)
- 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
public static HttpServer createSimpleServer(String docRoot, org.glassfish.grizzly.PortRange range)
- 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
public static HttpServer createSimpleServer(String docRoot, SocketAddress socketAddress)
- 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
public static HttpServer createSimpleServer(String docRoot, String host, int port)
- 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)
-
-