org.glassfish.grizzly.http.server
Class HttpServer

java.lang.Object
  extended by org.glassfish.grizzly.http.server.HttpServer

public class HttpServer
extends java.lang.Object


Field Summary
protected  GrizzlyJmxManager jmxManager
           
protected  JmxObject managementObject
           
 
Constructor Summary
HttpServer()
           
 
Method Summary
 void addListener(NetworkListener listener)
           Adds the specified listener to the server instance.
static HttpServer createSimpleServer()
           
static HttpServer createSimpleServer(java.lang.String path)
           
static HttpServer createSimpleServer(java.lang.String path, int port)
           
static HttpServer createSimpleServer(java.lang.String path, PortRange range)
           
protected  void disableJMX()
           
protected  void enableJMX()
           
 HttpHandler getHttpHandler()
           
 NetworkListener getListener(java.lang.String name)
           
 java.util.Collection<NetworkListener> getListeners()
           
 JmxObject getManagementObject(boolean clear)
           
 ServerConfiguration getServerConfiguration()
           
 boolean isStarted()
           
 NetworkListener removeListener(java.lang.String name)
           Removes the NetworkListener associated with the specified name.
 void start()
           Starts the HttpServer.
 void stop()
           Stops the HttpServer instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jmxManager

protected volatile GrizzlyJmxManager jmxManager

managementObject

protected volatile JmxObject managementObject
Constructor Detail

HttpServer

public HttpServer()
Method Detail

getServerConfiguration

public final ServerConfiguration getServerConfiguration()
Returns:
the ServerConfiguration used to configure this HttpServer instance

addListener

public 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.

Parameters:
listener - the NetworkListener to associate with this server instance.

getListener

public NetworkListener getListener(java.lang.String name)
Parameters:
name - the NetworkListener name.
Returns:
the NetworkListener, if any, associated with the specified name.

getListeners

public java.util.Collection<NetworkListener> getListeners()
Returns:
a read only Collection over the listeners associated with this HttpServer instance.

removeListener

public NetworkListener removeListener(java.lang.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.

Parameters:
name - the name of the NetworkListener to remove.

start

public void start()
           throws java.io.IOException

Starts the HttpServer.

Throws:
java.io.IOException - if an error occurs while attempting to start the server.

getHttpHandler

public HttpHandler getHttpHandler()
Returns:
the HttpHandler used by this HttpServer instance.

isStarted

public boolean isStarted()
Returns:
true if this HttpServer has been started.

getManagementObject

public JmxObject getManagementObject(boolean clear)

stop

public void stop()

Stops the HttpServer instance.


createSimpleServer

public static HttpServer createSimpleServer()
Returns:
a 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.

createSimpleServer

public static HttpServer createSimpleServer(java.lang.String path)
Parameters:
path - the document root.
Returns:
a 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.

createSimpleServer

public static HttpServer createSimpleServer(java.lang.String path,
                                            int port)
Parameters:
path - the document root.
port - the network port to which this listener will bind.
Returns:
a HttpServer configured to listen to requests on NetworkListener.DEFAULT_NETWORK_HOST:port, using the specified path as the server's document root.

createSimpleServer

public static HttpServer createSimpleServer(java.lang.String path,
                                            PortRange range)
Parameters:
path - the document root.
range - port range to attempt to bind to.
Returns:
a HttpServer configured to listen to requests on NetworkListener.DEFAULT_NETWORK_HOST:[port-range], using the specified path as the server's document root.

enableJMX

protected void enableJMX()

disableJMX

protected void disableJMX()


Copyright © 2011 Oracle Corpration. All Rights Reserved.