|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.servlet.GenericServlet
org.apache.sling.api.servlets.SlingSafeMethodsServlet
org.apache.sling.api.servlets.SlingAllMethodsServlet
public class SlingAllMethodsServlet
Helper base class for data modifying Servlets used in Sling. This class
extends the SlingSafeMethodsServlet by support for the POST,
PUT and DELETE methods.
Implementors note: The methods in this class are all declared to throw the exceptions according to the intentions of the Servlet API rather than throwing their Sling RuntimeException counter parts. This is done to easy the integration with traditional servlets.
for more information on supporting more HTTP
methods,
Serialized Form| Constructor Summary | |
|---|---|
SlingAllMethodsServlet()
|
|
| Method Summary | |
|---|---|
protected void |
doDelete(SlingHttpServletRequest request,
SlingHttpServletResponse response)
Called by the mayService(SlingHttpServletRequest, SlingHttpServletResponse) method to
handle an HTTP DELETE request. |
protected void |
doPost(SlingHttpServletRequest request,
SlingHttpServletResponse response)
Called by the mayService(SlingHttpServletRequest, SlingHttpServletResponse) method to
handle an HTTP POST request. |
protected void |
doPut(SlingHttpServletRequest request,
SlingHttpServletResponse response)
Called by the mayService(SlingHttpServletRequest, SlingHttpServletResponse) method to
handle an HTTP PUT request. |
protected java.lang.StringBuffer |
getAllowedRequestMethods(java.util.Map<java.lang.String,java.lang.reflect.Method> declaredMethods)
Helper method called by SlingSafeMethodsServlet.doOptions(SlingHttpServletRequest, SlingHttpServletResponse) to calculate
the value of the Allow header sent as the response to the HTTP
OPTIONS request. |
protected boolean |
isMethodValid(java.lang.reflect.Method method,
java.lang.String className)
Returns true if method is not
null and the method is not defined in the class named by
className. |
protected boolean |
mayService(SlingHttpServletRequest request,
SlingHttpServletResponse response)
Tries to handle the request by calling a Java method implemented for the respective HTTP request method. |
| Methods inherited from class org.apache.sling.api.servlets.SlingSafeMethodsServlet |
|---|
doGeneric, doGet, doHead, doOptions, doTrace, getServletInfo, handleMethodNotImplemented, service, service |
| Methods inherited from class javax.servlet.GenericServlet |
|---|
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, init, log, log |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SlingAllMethodsServlet()
| Method Detail |
|---|
protected void doPost(SlingHttpServletRequest request,
SlingHttpServletResponse response)
throws javax.servlet.ServletException,
java.io.IOException
mayService(SlingHttpServletRequest, SlingHttpServletResponse) method to
handle an HTTP POST request.
This default implementation reports back to the client that the method is not supported.
Implementations of this class should overwrite this method with their implementation for the HTTP POST method support.
request - The HTTP requestresponse - The HTTP response
javax.servlet.ServletException - Not thrown by this implementation.
java.io.IOException - If the error status cannot be reported back to the
client.
protected void doPut(SlingHttpServletRequest request,
SlingHttpServletResponse response)
throws javax.servlet.ServletException,
java.io.IOException
mayService(SlingHttpServletRequest, SlingHttpServletResponse) method to
handle an HTTP PUT request.
This default implementation reports back to the client that the method is not supported.
Implementations of this class should overwrite this method with their implementation for the HTTP PUT method support.
request - The HTTP requestresponse - The HTTP response
javax.servlet.ServletException - Not thrown by this implementation.
java.io.IOException - If the error status cannot be reported back to the
client.
protected void doDelete(SlingHttpServletRequest request,
SlingHttpServletResponse response)
throws javax.servlet.ServletException,
java.io.IOException
mayService(SlingHttpServletRequest, SlingHttpServletResponse) method to
handle an HTTP DELETE request.
This default implementation reports back to the client that the method is not supported.
Implementations of this class should overwrite this method with their implementation for the HTTP DELETE method support.
request - The HTTP requestresponse - The HTTP response
javax.servlet.ServletException - Not thrown by this implementation.
java.io.IOException - If the error status cannot be reported back to the
client.
protected boolean mayService(SlingHttpServletRequest request,
SlingHttpServletResponse response)
throws javax.servlet.ServletException,
java.io.IOException
This implementation first calls the base class implementation and only if
the base class cannot dispatch will try to dispatch the supported methods
POST, PUT and DELETE and returns
true if any of these methods is requested. Otherwise
false is just returned.
mayService in class SlingSafeMethodsServletrequest - The HTTP requestresponse - The HTTP response
true if the requested method (request.getMethod())
is known. Otherwise false is returned.
javax.servlet.ServletException - Forwarded from any of the dispatched methods
java.io.IOException - Forwarded from any of the dispatched methodsprotected java.lang.StringBuffer getAllowedRequestMethods(java.util.Map<java.lang.String,java.lang.reflect.Method> declaredMethods)
SlingSafeMethodsServlet.doOptions(SlingHttpServletRequest, SlingHttpServletResponse) to calculate
the value of the Allow header sent as the response to the HTTP
OPTIONS request.
This implementation overwrites the base class implementation adding support for the POST, PUT and DELETE methods in addition to the methods returned by the base class implementation.
getAllowedRequestMethods in class SlingSafeMethodsServletdeclaredMethods - The public and protected methods declared in the
extension of this class.
StringBuffer containing the list of HTTP methods
supported.
protected boolean isMethodValid(java.lang.reflect.Method method,
java.lang.String className)
true if method is not
null and the method is not defined in the class named by
className.
This method may be used to make sure a method is actually overwritten and not just the default implementation.
method - The Method to checkclassName - The name of class assumed to contained the initial
declaration of the method.
true if method is not
null and the methods declaring class is not the
given class.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||