|
SRJRCFrames v0.1.296 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.schwarzrot.net.http.service.AbstractProtocolHandler
public abstract class AbstractProtocolHandler
base class for protocol handler, where protocol is the response format of HTTP requests. Main purpose is a general handling of error- and help-messages.
Field Summary | |
---|---|
protected static String |
HELP
|
protected static String |
STD_MSG_404
|
Constructor Summary | |
---|---|
AbstractProtocolHandler()
|
Method Summary | |
---|---|
protected boolean |
checkGlobalCommands(PrintWriter out,
Map<String,String> header,
Map<String,String> request)
|
void |
doHelp(PrintWriter out)
prints the help about the service, the supported calls and their parameters. |
void |
err404(PrintWriter out,
String command)
sends an error message to the client |
Map<String,RequestHandler> |
getRequestHandlers()
accessor to the map of RequestHandler . |
HTTPServer<?> |
getServer()
accessor the the HTTP server engine. |
void |
processRequest(Socket clientSocket,
Map<String,String> header,
Map<String,String> request)
the entrypoint for request processing. |
void |
setRequestHandlers(Map<String,RequestHandler> requestHandlerMap)
accessor to set the map of RequestHandler . |
void |
setup(HTTPServer<?> srv)
used for asynchronous setup. |
void |
status(PrintWriter out,
HttpStatusCode status)
|
void |
status(PrintWriter out,
HttpStatusCode status,
String message)
|
protected abstract String |
usage()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String STD_MSG_404
protected static final String HELP
Constructor Detail |
---|
public AbstractProtocolHandler()
Method Detail |
---|
public void doHelp(PrintWriter out)
ProtocolHandler
RequestHandler
on invalid/incomplete
calls.
doHelp
in interface ProtocolHandler
out
- - the printwriter to used to send a message to clientpublic void err404(PrintWriter out, String command)
ProtocolHandler
err404
in interface ProtocolHandler
out
- - the PrintWriter
used to write a client responsecommand
- - specify the requested location, that could not be resolvedpublic Map<String,RequestHandler> getRequestHandlers()
ProtocolHandler
RequestHandler
. The request handlers are
plugged in by application context configuration
getRequestHandlers
in interface ProtocolHandler
public HTTPServer<?> getServer()
ProtocolHandler
getServer
in interface ProtocolHandler
public void processRequest(Socket clientSocket, Map<String,String> header, Map<String,String> request) throws Exception
ProtocolHandler
processRequest
in interface ProtocolHandler
clientSocket
- - the socket for client communicationheader
- - the parameters from HTTP headerrequest
- - the request parameters
Exception
- - if anything goes wrongpublic void setRequestHandlers(Map<String,RequestHandler> requestHandlerMap)
ProtocolHandler
RequestHandler
. The request handlers
are plugged in by application context configuration
setRequestHandlers
in interface ProtocolHandler
requestHandlerMap
- - the map of RequestHandler
public void setup(HTTPServer<?> srv)
ProtocolHandler
HTTPServer
will start the rest of configuration, before accepting connections from
clients.
setup
in interface ProtocolHandler
srv
- - the HTTPServer instancepublic void status(PrintWriter out, HttpStatusCode status)
status
in interface ProtocolHandler
public void status(PrintWriter out, HttpStatusCode status, String message)
status
in interface ProtocolHandler
protected boolean checkGlobalCommands(PrintWriter out, Map<String,String> header, Map<String,String> request) throws Exception
Exception
protected abstract String usage()
|
SRJRCFrames v0.1.296 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |