Top Fields Constructors Methods
org.glassfish.grizzly.http.server

public Class HttpServer

extends Object
Class Inheritance
Imports
java.io.IOException, java.net.InetSocketAddress, .SocketAddress, java.util.Collection, .Collections, .HashMap, .HashSet, .Map, .Set, java.util.concurrent.ExecutorService, .Executors, .ThreadFactory, .TimeUnit, java.util.concurrent.atomic.AtomicInteger, java.util.logging.Level, .Logger, org.glassfish.grizzly.CompletionHandler, .ConnectionProbe, .EmptyCompletionHandler, .Grizzly, .GrizzlyFuture, .PortRange, .Processor, .Transport, .TransportProbe, org.glassfish.grizzly.attributes.AttributeBuilder, org.glassfish.grizzly.filterchain.FilterChain, .FilterChainBuilder, .TransportFilter, org.glassfish.grizzly.http.CompressionConfig, .CompressionConfig.CompressionMode, .ContentEncoding, .GZipContentEncoding, .LZMAContentEncoding, org.glassfish.grizzly.http.server.filecache.FileCache, org.glassfish.grizzly.http.server.jmxbase.JmxEventListener, org.glassfish.grizzly.impl.FutureImpl, org.glassfish.grizzly.jmxbase.GrizzlyJmxManager, org.glassfish.grizzly.memory.MemoryProbe, org.glassfish.grizzly.monitoring.MonitoringConfig, .MonitoringUtils, org.glassfish.grizzly.nio.transport.TCPNIOTransport, org.glassfish.grizzly.ssl.SSLBaseFilter, .SSLContextConfigurator, .SSLEngineConfigurator, org.glassfish.grizzly.threadpool.DefaultWorkerThread, .ThreadPoolConfig, .ThreadPoolProbe, org.glassfish.grizzly.utils.DelayedExecutor, .Futures, .IdleTimeoutFilter

Field Summary

Modifier and TypeField and Description
private volatile ExecutorService
pack-priv volatile DelayedExecutor
private final HttpHandlerChain
httpHandlerChain

HttpHandler, which processes HTTP requests

protected volatile GrizzlyJmxManager
private final Map<String, NetworkListener>
listeners

Mapping of NetworkListeners, by name, used by this server instance.

private static final Logger
protected volatile Object
private final ServerConfiguration
serverConfig

Configuration details for this server instance.

private FutureImpl<HttpServer>
shutdownFuture

Future to control graceful shutdown status

private State
state

Flag indicating whether or not this server instance has been started.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public synchronized void
addListener(final NetworkListener
the NetworkListener to associate with this server instance.
listener
)

Adds the specified listener to the server instance.

private void
protected Set<ContentEncoding>
private void
private void
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

public static HttpServer
createSimpleServer(final String
the document root, can be null when no static pages are needed
docRoot
)

Returns: a HttpServer configured to listen to requests on NetworkListener#DEFAULT_NETWORK_HOST:NetworkListener#DEFAULT_NETWORK_PORT, using the specified docRoot as the server's document root

public static HttpServer
createSimpleServer(final String
the document root, can be null when no static pages are needed
docRoot
,
final int
the network port to which this listener will bind
port
)

Returns: a HttpServer configured to listen to requests on NetworkListener#DEFAULT_NETWORK_HOST:port, using the specified docRoot as the server's document root

public static HttpServer
createSimpleServer(final String
the document root, can be null when no static pages are needed
docRoot
,
final PortRange
port range to attempt to bind to
range
)

Returns: a HttpServer configured to listen to requests on NetworkListener#DEFAULT_NETWORK_HOST:[port-range], using the specified docRoot as the server's document root

public static HttpServer
createSimpleServer(final String
the document root, can be null when no static pages are needed
docRoot
,
final SocketAddress
the endpoint address to which this listener will bind
socketAddress
)

Returns: a HttpServer configured to listen to requests on socketAddress, using the specified docRoot as the server's document root

public static HttpServer
createSimpleServer(final String
the document root, can be null when no static pages are needed
docRoot
,
final String
the network port to which this listener will bind
host
,
final int
the network port to which this listener will bind
port
)

Returns: a HttpServer configured to listen to requests on host:port, using the specified docRoot as the server's document root

public static HttpServer
createSimpleServer(final String
the document root, can be null when no static pages are needed
docRoot
,
final String
the network port to which this listener will bind
host
,
final PortRange
port range to attempt to bind to
range
)

Returns: a HttpServer configured to listen to requests on host:[port-range], using the specified docRoot as the server's document root

protected void
protected void
public HttpHandler
getHttpHandler()

Returns: the HttpHandler used by this HttpServer instance.

public synchronized NetworkListener
getListener(final String
the NetworkListener name.
name
)

Returns: the NetworkListener, if any, associated with the specified name.

public synchronized Collection<NetworkListener>
getListeners()

Returns: a read only Collection over the listeners associated with this HttpServer instance.

public Object
getManagementObject(boolean clear)

public final ServerConfiguration
getServerConfiguration()

Returns: the ServerConfiguration used to configure this HttpServer instance

public boolean
isStarted()

Returns: true if this HttpServer has been started.

pack-priv synchronized void
onAddHttpHandler(HttpHandler httpHandler, final HttpHandlerRegistration[] registrations)

Modifies handlers mapping during runtime.

pack-priv synchronized void
onRemoveHttpHandler(HttpHandler httpHandler)

Modifies handlers mapping during runtime.

public synchronized NetworkListener

Returns:

NetworkListener, that has been removed, or null if the listener with the given name doesn't exist
removeListener
(final String
the name of the NetworkListener to remove.
name
)

Removes the NetworkListener associated with the specified name.

private void
public synchronized GrizzlyFuture<HttpServer>
shutdown(final long gracePeriod, final TimeUnit timeUnit)

public synchronized GrizzlyFuture<HttpServer>
shutdown()

Gracefully shuts down the HttpServer instance.

public synchronized void
shutdownNow()

Immediately shuts down the HttpServer instance.

public synchronized void
start()

Starts the HttpServer.

public void
stop()
Deprecated use shutdownNow()

Immediately shuts down the HttpServer instance.

private void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

auxExecutorServiceback to summary
private volatile ExecutorService auxExecutorService
delayedExecutorback to summary
pack-priv volatile DelayedExecutor delayedExecutor
httpHandlerChainback to summary
private final HttpHandlerChain httpHandlerChain

HttpHandler, which processes HTTP requests

jmxManagerback to summary
protected volatile GrizzlyJmxManager jmxManager
listenersback to summary
private final Map<String, NetworkListener> listeners

Mapping of NetworkListeners, by name, used by this server instance.

LOGGERback to summary
private static final Logger LOGGER
managementObjectback to summary
protected volatile Object managementObject
serverConfigback to summary
private final ServerConfiguration serverConfig

Configuration details for this server instance.

shutdownFutureback to summary
private FutureImpl<HttpServer> shutdownFuture

Future to control graceful shutdown status

stateback to summary
private State state

Flag indicating whether or not this server instance has been started.

Constructor Detail

HttpServerback to summary
public HttpServer()

Method Detail

addListenerback to summary
public synchronized void addListener(final 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:NetworkListener

the NetworkListener to associate with this server instance.

configureAuxThreadPoolback to summary
private void configureAuxThreadPool()
configureCompressionEncodingsback to summary
protected Set<ContentEncoding> configureCompressionEncodings(final NetworkListener listener)
configureListenerback to summary
private void configureListener(final NetworkListener listener)
configureMonitoringback to summary
private void configureMonitoring(final NetworkListener listener)
Annotations
@SuppressWarnings:unchecked
createSimpleServerback to summary
public static HttpServer createSimpleServer()
Returns:HttpServer

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

createSimpleServerback to summary
public static HttpServer createSimpleServer(final String docRoot)
Parameters
docRoot:String

the document root, can be null when no static pages are needed

Returns:HttpServer

a HttpServer configured to listen to requests on NetworkListener#DEFAULT_NETWORK_HOST:NetworkListener#DEFAULT_NETWORK_PORT, using the specified docRoot as the server's document root

createSimpleServerback to summary
public static HttpServer createSimpleServer(final String docRoot, final int port)
Parameters
docRoot:String

the document root, can be null when no static pages are needed

port:int

the network port to which this listener will bind

Returns:HttpServer

a HttpServer configured to listen to requests on NetworkListener#DEFAULT_NETWORK_HOST:port, using the specified docRoot as the server's document root

createSimpleServerback to summary
public static HttpServer createSimpleServer(final String docRoot, final PortRange range)
Parameters
docRoot:String

the document root, can be null when no static pages are needed

range:PortRange

port range to attempt to bind to

Returns:HttpServer

a HttpServer configured to listen to requests on NetworkListener#DEFAULT_NETWORK_HOST:[port-range], using the specified docRoot as the server's document root

createSimpleServerback to summary
public static HttpServer createSimpleServer(final String docRoot, final SocketAddress socketAddress)
Parameters
docRoot:String

the document root, can be null when no static pages are needed

socketAddress:SocketAddress

the endpoint address to which this listener will bind

Returns:HttpServer

a HttpServer configured to listen to requests on socketAddress, using the specified docRoot as the server's document root

createSimpleServerback to summary
public static HttpServer createSimpleServer(final String docRoot, final String host, final int port)
Parameters
docRoot:String

the document root, can be null when no static pages are needed

host:String

the network port to which this listener will bind

port:int

the network port to which this listener will bind

Returns:HttpServer

a HttpServer configured to listen to requests on host:port, using the specified docRoot as the server's document root

createSimpleServerback to summary
public static HttpServer createSimpleServer(final String docRoot, final String host, final PortRange range)
Parameters
docRoot:String

the document root, can be null when no static pages are needed

host:String

the network port to which this listener will bind

range:PortRange

port range to attempt to bind to

Returns:HttpServer

a HttpServer configured to listen to requests on host:[port-range], using the specified docRoot as the server's document root

disableJMXback to summary
protected void disableJMX()
enableJMXback to summary
protected void enableJMX()
getHttpHandlerback to summary
public HttpHandler getHttpHandler()
Returns:HttpHandler

the HttpHandler used by this HttpServer instance.

getListenerback to summary
public synchronized NetworkListener getListener(final String name)
Parameters
name:String

the NetworkListener name.

Returns:NetworkListener

the NetworkListener, if any, associated with the specified name.

getListenersback to summary
public synchronized Collection<NetworkListener> getListeners()
Returns:Collection<NetworkListener>

a read only Collection over the listeners associated with this HttpServer instance.

getManagementObjectback to summary
public Object getManagementObject(boolean clear)
getServerConfigurationback to summary
public final ServerConfiguration getServerConfiguration()
Returns:ServerConfiguration

the ServerConfiguration used to configure this HttpServer instance

isStartedback to summary
public boolean isStarted()
Returns:boolean

true if this HttpServer has been started.

onAddHttpHandlerback to summary
pack-priv synchronized void onAddHttpHandler(HttpHandler httpHandler, final HttpHandlerRegistration[] registrations)

Modifies handlers mapping during runtime.

onRemoveHttpHandlerback to summary
pack-priv synchronized void onRemoveHttpHandler(HttpHandler httpHandler)

Modifies handlers mapping during runtime.

removeListenerback to summary
public synchronized NetworkListener removeListener(final 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:String

the name of the NetworkListener to remove.

Returns:NetworkListener

NetworkListener, that has been removed, or null if the listener with the given name doesn't exist

Annotations
@SuppressWarnings:UnusedReturnValue
setupHttpHandlerback to summary
private void setupHttpHandler()
shutdownback to summary
public synchronized GrizzlyFuture<HttpServer> shutdown(final long gracePeriod, final TimeUnit timeUnit)
shutdownback to summary
public synchronized GrizzlyFuture<HttpServer> shutdown()

Gracefully shuts down the HttpServer instance.

shutdownNowback to summary
public synchronized void shutdownNow()

Immediately shuts down the HttpServer instance.

startback to summary
public synchronized void start() throws IOException

Starts the HttpServer.

Exceptions
IOException:
if an error occurs while attempting to start the server.
stopback to summary
public void stop()

Deprecated

use shutdownNow()

Immediately shuts down the HttpServer instance.

Annotations
@Deprecated
stopAuxThreadPoolback to summary
private void stopAuxThreadPool()
tearDownHttpHandlerback to summary
private void tearDownHttpHandler()