|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.abstracthorizon.danube.http.BaseReflectionHTTPConnectionHandler
public class BaseReflectionHTTPConnectionHandler
This is base http connection handler that splits different HTTP methods
(GET, POST, PUT, DELETE, HEAD, TRACE, OPTIONS and possibly others) to
methods with names starting with "method"l and ending with HTTP method name.
For instanceof methodGET
, methodPOST
, etc.
This handler also defines default HEAD and TRACE method implementations
(methodHEAD
and methodTRACE
). These can be easily
disabled with setNoDefaultHead(boolean)
and setNoDefaultTrace(boolean)
properties.
That does not affect user defined HEAD and TRACE implementations.
HTTP method OPTIONS is handled by methodOPTIONS(HTTPConnection)
method.
It returns all those that are defined in the class.
Field Summary | |
---|---|
protected Map<String,Method> |
cachedMethods
|
protected ConnectionHandler |
errorResponse
Error response |
protected boolean |
noDefaultHead
Flag that shows should default HEAD handling method be included or not ( methodHead(HttpConnection) |
protected boolean |
noDefaultTrace
Flag that shows should default TRACE handling method be included or not ( methodTrace(HttpConnection) |
Constructor Summary | |
---|---|
BaseReflectionHTTPConnectionHandler()
Constructor |
Method Summary | |
---|---|
protected void |
cacheMethods()
Caches HTTP to java methods. |
ConnectionHandler |
getErrorResponse()
Returns error response connection handler |
boolean |
getNoDefaultHead()
Returns if default HEAD handling method is to be included or not |
boolean |
getNoDefaultTrace()
Returns if default TRACE handling method is to be included or not |
void |
handleConnection(Connection connection)
Handles connection |
protected void |
invokeMethod(HTTPConnection httpConnection,
String methodName)
Invokes object's method |
void |
methodHEAD(HTTPConnection httpConnection)
Handles OPTIONS HTTP method |
void |
methodOPTIONS(HTTPConnection httpConnection)
Handles OPTIONS HTTP method |
void |
methodTRACE(HTTPConnection httpConnection)
Handles OPTIONS HTTP method |
void |
returnError(HTTPConnection httpConnection,
Status status)
|
void |
returnSimpleContent(HTTPConnection httpConnection,
Status status,
String contentType,
String content)
|
void |
setErrorResponse(ConnectionHandler errorResponse)
Sets error response connection handler |
void |
setNoDefaultHead(boolean noDefaultHead)
Sets if default HEAD handling method is to be included or not |
void |
setNoDefaultTrace(boolean noDefaultTrace)
Sets if default TRACE handling method is to be included or not |
protected void |
updateDefaultHeadMethod()
Updates the state of default HEAD method implementation. |
protected void |
updateDefaultTraceMethod()
Updates the state of default TRACE method implementation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Map<String,Method> cachedMethods
protected boolean noDefaultHead
methodHead(HttpConnection)
protected boolean noDefaultTrace
methodTrace(HttpConnection)
protected ConnectionHandler errorResponse
Constructor Detail |
---|
public BaseReflectionHTTPConnectionHandler()
Method Detail |
---|
public ConnectionHandler getErrorResponse()
public void setErrorResponse(ConnectionHandler errorResponse)
errorResponse
- error response handlerpublic boolean getNoDefaultHead()
true
if default HEAD handling method is to be includedpublic void setNoDefaultHead(boolean noDefaultHead)
noDefaultHead
- should default HEAD handling method is to be included or notprotected void updateDefaultHeadMethod()
public boolean getNoDefaultTrace()
true
if default TRACE handling method is to be includedpublic void setNoDefaultTrace(boolean noDefaultTrace)
noDefaultTrace
- should default TRACE handling method is to be included or notprotected void updateDefaultTraceMethod()
protected void cacheMethods()
HTTPConnection
as a single parameter are cached.
public void handleConnection(Connection connection)
handleConnection
in interface ConnectionHandler
connection
- connectionprotected void invokeMethod(HTTPConnection httpConnection, String methodName)
httpConnection
- http connectionmethodName
- method namepublic void methodOPTIONS(HTTPConnection httpConnection)
httpConnection
- HTTP connectionpublic void methodTRACE(HTTPConnection httpConnection)
httpConnection
- HTTP connectionpublic void methodHEAD(HTTPConnection httpConnection)
httpConnection
- HTTP connectionpublic void returnError(HTTPConnection httpConnection, Status status)
public void returnSimpleContent(HTTPConnection httpConnection, Status status, String contentType, String content)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |