Interface Handler
- All Known Subinterfaces:
Filter
- All Known Implementing Classes:
AclSwitchHandler
,AsteriskAGIHandler
,AsteriskHandler
,BasicAuthHandler
,CacheManager
,CgiHandler
,ChainHandler
,ChainSawHandler
,ChownHandler
,ConfigFileHandler
,CookieFilter
,CookieSessionHandler
,CopyContentFilter
,DefaultFileHandler
,DeferredHandler
,DelayHandler
,DialogHandler
,DigestAuthHandler
,DirectoryHandler
,DirectoryTemplate
,DynamicConfigHandler
,ExecFilter
,ExprPropsHandler
,FileHandler
,FilterHandler
,GenericProxyHandler
,HistoryFilter
,HomeDirHandler
,JunkBusterHandler
,LogHandler
,MD5Filter
,MultiHostHandler
,MultipartSetTemplate
,MultiProxyHandler
,NotFoundHandler
,PlainFilter
,PollHandler
,PropertiesCacheManager
,PropertiesHandler
,ProxyHandler
,ProxyPropertiesHandler
,PublishHandler
,PushHandler
,PutHandler
,ReFilter
,ReflectHandler
,ReplaceFilter
,RePollHandler
,ResourceHandler
,ResourceLimitHandler
,RestartHandler
,RestartingMultiHostHandler
,RestrictClientHandler
,RolesHandler
,SessionFilter
,SetTemplate
,SimpleSessionHandler
,SMTPHandler
,StunnelHandler
,SubstPropsHandler
,SunNetAuthHandler
,SunProxy
,SupplyHandler
,TemplateFilter
,TemplateHandler
,UrlMapFilter
,UrlMapperHandler
,UrlSessionFilter
,VirtualHostHandler
The init(Server, String)
method is called before this
Handler
processes the first HTTP request, to allow it to
prepare itself, such as by allocating any resources needed for the
lifetime of the server
.
The respond(Request)
method is called to handle an HTTP request.
This method, and all methods it calls must be thread-safe since they may
handle HTTP requests from multiple sockets concurrently. However, each
concurrent request gets its own individual Request
object.
Any instance variables should be initialized in the
init(Server, String)
, and only referenced, but not set in the
respond(Request)
method. If any state needs to be retained,
it should be done either by associating it with the Request
object, or using the
session manager
.
Class statics should be avoided, as it is possible, and even common to
run multiple unrelated Brazil servers in the same JVM. As above, the
session manager
should be used instead.
- Version:
- 2.3
- Author:
- Stephen Uhler (stephen.uhler@sun.com), Colin Stevens (colin.stevens@sun.com)
-
Method Summary
-
Method Details
-
init
Initializes the handler.- Parameters:
server
- The HTTP server that created thisHandler
. TypicalHandler
s will useServer.props
to obtain run-time configuration information.prefix
- The handlers name. The string thisHandler
may prepend to all of the keys that it uses to extract configuration information fromServer.props
. This is set (by theServer
andChainHandler
) to help avoid configuration parameter namespace collisions.- Returns:
true
if thisHandler
initialized successfully,false
otherwise. Iffalse
is returned, thisHandler
should not be used.
-
respond
Responds to an HTTP request.- Parameters:
request
- TheRequest
object that represents the HTTP request.- Returns:
true
if the request was handled. A request was handled if a response was supplied to the client, typically by callingRequest.sendResponse()
orRequest.sendError
.- Throws:
IOException
- if there was an I/O error while sending the response to the client. Typically, in that case, theServer
will (try to) send an error message to the client and then close the client's connection.The
IOException
should not be used to silently ignore problems such as being unable to access some server-side resource (for example getting aFileNotFoundException
due to not being able to open a file). In that case, theHandler
's duty is to turn thatIOException
into a HTTP response indicating, in this case, that a file could not be found.
-