public class HttpServer extends Object
| Modifier and Type | Field and Description |
|---|---|
protected GrizzlyJmxManager |
jmxManager |
protected JmxObject |
managementObject |
| Constructor and Description |
|---|
HttpServer() |
protected volatile GrizzlyJmxManager jmxManager
protected volatile JmxObject managementObject
public final ServerConfiguration getServerConfiguration()
ServerConfiguration used to configure this
HttpServer instancepublic void addListener(NetworkListener listener)
Adds the specified listener to the server instance.
If the server is already running when this method is called, the listener will be started.
listener - the NetworkListener to associate with this
server instance.public NetworkListener getListener(String name)
name - the NetworkListener name.NetworkListener, if any, associated with the
specified name.public Collection<NetworkListener> getListeners()
read only Collection over the listeners
associated with this HttpServer instance.public NetworkListener removeListener(String name)
Removes the NetworkListener associated with the specified
name.
If the server is running when this method is invoked, the listener will be stopped before being returned.
name - the name of the NetworkListener to remove.public void start()
throws IOException
Starts the HttpServer.
IOException - if an error occurs while attempting to start the
server.public HttpHandler getHttpHandler()
HttpHandler used by this HttpServer
instance.public boolean isStarted()
true if this HttpServer has
been started.public JmxObject getManagementObject(boolean clear)
public void stop()
Stops the HttpServer instance.
public static HttpServer createSimpleServer()
HttpServer configured to listen to requests
on NetworkListener.DEFAULT_NETWORK_HOST:NetworkListener.DEFAULT_NETWORK_PORT,
using the directory in which the server was launched the server's document root.public static HttpServer createSimpleServer(String path)
path - the document root.HttpServer configured to listen to requests
on NetworkListener.DEFAULT_NETWORK_HOST:NetworkListener.DEFAULT_NETWORK_PORT,
using the specified path as the server's document root.public static HttpServer createSimpleServer(String path, int port)
path - the document root.port - the network port to which this listener will bind.HttpServer configured to listen to requests
on NetworkListener.DEFAULT_NETWORK_HOST:port,
using the specified path as the server's document root.public static HttpServer createSimpleServer(String path, PortRange range)
path - the document root.range - port range to attempt to bind to.HttpServer configured to listen to requests
on NetworkListener.DEFAULT_NETWORK_HOST:[port-range],
using the specified path as the server's document root.public static HttpServer createSimpleServer(String path, SocketAddress socketAddress)
path - the document root.socketAddress - the endpoint address to which this listener will bind.HttpServer configured to listen to requests
on socketAddress,
using the specified path as the server's document root.public static HttpServer createSimpleServer(String path, String host, int port)
path - the document root.host - the network port to which this listener will bind.port - the network port to which this listener will bind.HttpServer configured to listen to requests
on host:port,
using the specified path as the server's document root.public static HttpServer createSimpleServer(String path, String host, PortRange range)
path - the document root.host - the network port to which this listener will bind.range - port range to attempt to bind to.HttpServer configured to listen to requests
on host:[port-range],
using the specified path as the server's document root.protected void enableJMX()
protected void disableJMX()
protected Set<ContentEncoding> configureCompressionEncodings(NetworkListener listener)
Copyright © 2013 Oracle Corporation. All Rights Reserved.