Class HttpContext
java.lang.Object
com.sun.net.httpserver.HttpContext
HttpContext represents a mapping between the root URI
path of an application to a HttpHandler which is invoked to handle
requests destined for that path on the associated HttpServer or
HttpsServer.
HttpContext instances are created by the create methods in
HttpServer and HttpsServer.
A chain of Filter objects can be added to a HttpContext.
All exchanges processed by the context can be pre- and post-processed by each
Filter in the chain.
- Since:
- 1.6
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract AuthenticatorReturns the currently setAuthenticatorfor this context if one exists.abstract HttpHandlerReturns the handler for this context.abstract StringgetPath()Returns the path this context was created with.abstract HttpServerReturns the server this context was created with.abstract AuthenticatorSets theAuthenticatorfor thisHttpContext.abstract voidsetHandler(HttpHandler handler) Sets the handler for this context, if not already set.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Constructor Details
-
HttpContext
protected HttpContext()Constructor for subclasses to call.
-
-
Method Details
-
getHandler
Returns the handler for this context.- Returns:
- the
HttpHandlerfor this context
-
setHandler
Sets the handler for this context, if not already set.- Parameters:
handler- the handler to set for this context- Throws:
IllegalArgumentException- if the context for this handler is already set.NullPointerException- if handler isnull
-
getPath
Returns the path this context was created with.- Returns:
- the context of this path
-
getServer
Returns the server this context was created with.- Returns:
- the context of this server
-
getAttributes
-
getFilters
-
setAuthenticator
Sets theAuthenticatorfor thisHttpContext. Once an authenticator is established on a context, all client requests must be authenticated, and the given object will be invoked to validate each request. Each call to this method replaces any previous value set.- Parameters:
auth- theAuthenticatorto set. Ifnullthen any previously setAuthenticatoris removed, and client authentication will no longer be required.- Returns:
- the previous
Authenticator, if any set, ornullotherwise.
-
getAuthenticator
Returns the currently setAuthenticatorfor this context if one exists.- Returns:
- this HttpContext's
Authenticator, ornullif none is set
-