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

public abstract Class HttpHandler

extends Object
Class Inheritance
Known Direct Subclasses
org.glassfish.grizzly.http.server.StaticHttpHandlerBase, org.glassfish.grizzly.http.server.HttpHandlerChain
Imports
java.io.CharConversionException, .IOException, java.nio.charset.Charset, java.util.concurrent.Executor, java.util.logging.Level, .Logger, org.glassfish.grizzly.Connection, .Grizzly, .ReadHandler, .WriteHandler, org.glassfish.grizzly.filterchain.FilterChainContext, org.glassfish.grizzly.http.HttpRequestPacket, org.glassfish.grizzly.http.server.util.DispatcherHelper, .HtmlHelper, .MappingData, org.glassfish.grizzly.http.util.Header, .HttpStatus, .RequestURIRef, org.glassfish.grizzly.localization.LogMessages, org.glassfish.grizzly.utils.Charsets

Base class to use when Request/Response/InputStream/OutputStream are needed to implement a customized HTTP container/extension to the HTTP module. The HttpHandler provides developers with a simple and consistent mechanism for extending the functionality of the HTTP WebServer and for bridging existing HTTP based technology like JRuby-on-Rail, Servlet, Bayeux Protocol or any HTTP based protocol.
Author
Jeanfrancois Arcand

Field Summary

Modifier and TypeField and Description
private boolean
allowCustomStatusMessage

Are custom status messages (reason phrases) allowed?

private boolean
allowEncodedSlash

Allow request that uses encoded slash.

private boolean
decodeURL

Is the URL decoded

private static final RequestExecutorProvider
private static final Logger
private final String
name

HttpHandler name

private Charset
requestURIEncoding

Request URI encoding

Constructor Summary

AccessConstructor and Description
public
HttpHandler()

Create HttpHandler.

public
HttpHandler(String name)

Create HttpHandler with the specific name.

Method Summary

Modifier and TypeMethod and Description
public void
destroy()

Invoked when the HttpServer and may be overridden by custom implementations to perform implementation specific resource reclaimation tasks.

pack-priv boolean

Returns:

true if the Request has already been processed in the current Thread, or false otherwise
doHandle
(final Request request, final Response response)

Pre-processes HttpHandler Request and Response, checks the HTTP acknowledgment and decodes URL if required.

protected ErrorPageGenerator

Returns:

the ErrorPageGenerator, that might be used (if an error occurs) during Request processing
getErrorPageGenerator
(final Request request)

Returns the ErrorPageGenerator, that might be used (if an error occurs) during Request processing.

public String

Returns:

the HttpHandler name.
getName
()

Get the HttpHandler name.

public RequestExecutorProvider
public Charset

Returns:

the request URI encoding used by this HttpHandler.
getRequestURIEncoding
()

Get the request URI encoding used by this HttpHandler.

protected String
getSessionCookieName()

Returns: session cookie name, if not set default JSESSIONID name will be used

protected SessionManager
getSessionManager(final Request request)

Returns: the SessionManager to be used.

public boolean

Returns:

true if custom status messages (reason phrases) are allowed for this response, or false otherwise.
isAllowCustomStatusMessage
()

Returns true if custom status messages (reason phrases) are allowed for this response, or false otherwise.

public boolean

Returns:

Is HTTP URL request allowed to contains encoded slash.
isAllowEncodedSlash
()

Is HTTP URL request allowed to contains encoded slash.

private boolean
runService(final Request request, final Response response)

protected boolean

Returns:

true if request processing should continue after acknowledgment of the expectation, otherwise return false.
sendAcknowledgment
(final Request
the Request.
request
,
final Response response)

The default implementation will acknowledge an Expect: 100-Continue with a response line with the status 100 followed by the final response to this request.

public abstract void
service(Request request, Response response)

This method should contain the logic for any HTTP extension to the Grizzly HTTP web server.

public void
setAllowCustomStatusMessage(boolean
true if custom status messages (reason phrases) are allowed for this response, or false otherwise.
allowCustomStatusMessage
)

Sets if the custom status messages (reason phrases) are allowed for this response.

public void
setAllowEncodedSlash(boolean
true
allowEncodedSlash
)

When true, URL that contains encoded slash will be allowed.

protected void
setDecodeUrl(boolean decodeURL)

Should this class decode the URL

protected void
setDispatcherHelper(final DispatcherHelper dispatcherHelper)

public void
setRequestURIEncoding(final Charset
the request URI encoding used by this HttpHandler.
requestURIEncoding
)

Set the request URI encoding used by this HttpHandler.

public void
setRequestURIEncoding(final String
the request URI encoding used by this HttpHandler.
requestURIEncoding
)

Set the request URI encoding used by this HttpHandler.

public void
start()

Called when the HttpHandler's container is started by invoking HttpServer#start.

protected static void
updatePaths(final Request request, final MappingData mappingData)

Utility method to update Request path values.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allowCustomStatusMessageback to summary
private boolean allowCustomStatusMessage

Are custom status messages (reason phrases) allowed?

allowEncodedSlashback to summary
private boolean allowEncodedSlash

Allow request that uses encoded slash.

decodeURLback to summary
private boolean decodeURL

Is the URL decoded

DEFAULT_REQUEST_EXECUTOR_PROVIDERback to summary
private static final RequestExecutorProvider DEFAULT_REQUEST_EXECUTOR_PROVIDER
LOGGERback to summary
private static final Logger LOGGER
nameback to summary
private final String name

HttpHandler name

requestURIEncodingback to summary
private Charset requestURIEncoding

Request URI encoding

Constructor Detail

HttpHandlerback to summary
public HttpHandler()

Create HttpHandler.

HttpHandlerback to summary
public HttpHandler(String name)

Create HttpHandler with the specific name.

Method Detail

destroyback to summary
public void destroy()

Invoked when the HttpServer and may be overridden by custom implementations to perform implementation specific resource reclaimation tasks. By default, this method does nothing.

doHandleback to summary
pack-priv boolean doHandle(final Request request, final Response response) throws Exception

Pre-processes HttpHandler Request and Response, checks the HTTP acknowledgment and decodes URL if required. Then passes control to service(Request, Response).

Parameters
request:Request

the Request

response:Response

the Response

Returns:boolean

true if the Request has already been processed in the current Thread, or false otherwise

Exceptions
Exception:
if an error occurs serving a static resource or from the invocation of service(Request, Response)
getErrorPageGeneratorback to summary
protected ErrorPageGenerator getErrorPageGenerator(final Request request)

Returns the ErrorPageGenerator, that might be used (if an error occurs) during Request processing.

Parameters
request:Request

Request

Returns:ErrorPageGenerator

the ErrorPageGenerator, that might be used (if an error occurs) during Request processing

getNameback to summary
public String getName()

Get the HttpHandler name.

Returns:String

the HttpHandler name.

getRequestExecutorProviderback to summary
public RequestExecutorProvider getRequestExecutorProvider()
Returns:RequestExecutorProvider

the RequestExecutorProvider responsible for executing user's code in HttpHandler#service(org.glassfish.grizzly.http.server.Request, org.glassfish.grizzly.http.server.Response) and notifying ReadHandler, WriteHandler registered by the user.

getRequestURIEncodingback to summary
public Charset getRequestURIEncoding()

Get the request URI encoding used by this HttpHandler.

Returns:Charset

the request URI encoding used by this HttpHandler.

getSessionCookieNameback to summary
protected String getSessionCookieName()
Returns:String

session cookie name, if not set default JSESSIONID name will be used

getSessionManagerback to summary
protected SessionManager getSessionManager(final Request request)
Parameters
request:Request

Request

Returns:SessionManager

the SessionManager to be used. null value implies DefaultSessionManager

isAllowCustomStatusMessageback to summary
public boolean isAllowCustomStatusMessage()

Returns true if custom status messages (reason phrases) are allowed for this response, or false otherwise.

Returns:boolean

true if custom status messages (reason phrases) are allowed for this response, or false otherwise.

isAllowEncodedSlashback to summary
public boolean isAllowEncodedSlash()

Is HTTP URL request allowed to contains encoded slash.

Returns:boolean

Is HTTP URL request allowed to contains encoded slash.

runServiceback to summary
private boolean runService(final Request request, final Response response) throws Exception
sendAcknowledgmentback to summary
protected boolean sendAcknowledgment(final Request request, final Response response) throws IOException

The default implementation will acknowledge an Expect: 100-Continue with a response line with the status 100 followed by the final response to this request.

Parameters
request:Request

the Request.

response:Response

the Response.

Returns:boolean

true if request processing should continue after acknowledgment of the expectation, otherwise return false.

Exceptions
IOException:
if an error occurs sending the acknowledgment.
serviceback to summary
public abstract void service(Request request, Response response) throws Exception

This method should contain the logic for any HTTP extension to the Grizzly HTTP web server.

Parameters
request:Request

The Request

response:Response

The Response

setAllowCustomStatusMessageback to summary
public void setAllowCustomStatusMessage(boolean allowCustomStatusMessage)

Sets if the custom status messages (reason phrases) are allowed for this response.

Parameters
allowCustomStatusMessage:boolean

true if custom status messages (reason phrases) are allowed for this response, or false otherwise.

setAllowEncodedSlashback to summary
public void setAllowEncodedSlash(boolean allowEncodedSlash)

When true, URL that contains encoded slash will be allowed. When false, the URL will be rejected and considered as an invalid one.

Parameters
allowEncodedSlash:boolean

true

setDecodeUrlback to summary
protected void setDecodeUrl(boolean decodeURL)

Should this class decode the URL

setDispatcherHelperback to summary
protected void setDispatcherHelper(final DispatcherHelper dispatcherHelper)
setRequestURIEncodingback to summary
public void setRequestURIEncoding(final Charset requestURIEncoding)

Set the request URI encoding used by this HttpHandler.

Parameters
requestURIEncoding:Charset

the request URI encoding used by this HttpHandler.

setRequestURIEncodingback to summary
public void setRequestURIEncoding(final String requestURIEncoding)

Set the request URI encoding used by this HttpHandler.

Parameters
requestURIEncoding:String

the request URI encoding used by this HttpHandler.

startback to summary
public void start()

Called when the HttpHandler's container is started by invoking HttpServer#start. By default, it does nothing.

updatePathsback to summary
protected static void updatePaths(final Request request, final MappingData mappingData)

Utility method to update Request path values.