If any of the default HTTP methods is to be implemented just overwrite the
respective doXXX method. If additional methods should be supported implement
appropriate doXXX methods and overwrite the
method
to dispatch to the doXXX methods as appropriate and overwrite the
mayService(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse) to add the new method names.
getAllowedRequestMethods(java.util.Map)
Please note, that this base class is intended for applications where data is
only read. As such, this servlet by itself does not support the POST,
PUT and DELETE methods. Extensions of this class should
either overwrite any of the doXXX methods of this class or add support for
other read-only methods only. Applications wishing to support data
modification should rather use or extend the
which also contains support for the POST, PUT and
DELETE methods. This latter class should also be overwritten to
add support for HTTP methods modifying data.
SlingAllMethodsServlet
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.
SlingAllMethodsServlet
This base implementation just calls the
method dropping
the output. Implementations of this class may overwrite this method if
they have a more performing implementation. Otherwise, they may just keep
this base implementation.
doGet(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse)
request The HTTP requestresponse The HTTP response which only gets the headers setjavax.servlet.ServletException Forwarded from the
doGet(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse)
method called by this implementation.java.io.IOException Forwarded from the
doGet(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse)
method called by this implementation.mayService(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse) method to
handle an HTTP GET 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 GET method support.
request The HTTP requestresponse The HTTP responsejavax.servlet.ServletException Not thrown by this implementation.java.io.IOException If the error status cannot be reported back to the
client.Allow header on the response depending on the methods
declared in this class.
Extensions of this class should generally not overwrite this method but
rather the method. This method
gathers all declared public and protected methods for the concrete class
(upto but not including this class) and calls the
getAllowedRequestMethods(java.util.Map) method with the methods gathered.
The returned value is then used as the value of the getAllowedRequestMethods(java.util.Map)Allow
header set.
request The HTTP request object. Not used.response The HTTP response object on which the header is set.javax.servlet.ServletException Not thrown by this implementation.java.io.IOException Not thrown by this implementation.Extensions of this class do not generally need to overwrite this method as it contains all there is to be done to the TRACE method.
request The HTTP request whose headers are returned.response The HTTP response into which the request headers are
written.javax.servlet.ServletException Not thrown by this implementation.java.io.IOException May be thrown if there is an problem sending back the
request headers in the response stream.service(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse)
method to handle a request for an HTTP method, which is not known and
handled by this class or its extension.
This default implementation reports back to the client that the method is not supported.
This method should be overwritten with great care. It is better to
overwrite the
method and
add support for any extension HTTP methods through an additional doXXX
method.
mayService(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse)
request The HTTP requestresponse The HTTP responsejavax.servlet.ServletException Not thrown by this implementation.java.io.IOException If the error status cannot be reported back to the
client.
This base class implentation dispatches the HEAD,
GET, OPTIONS and TRACE to the
respective doXXX methods and returns true if
any of these methods is requested. Otherwise false is just
returned.
Implementations of this class may overwrite this method but should first
call this base implementation and in case false is
returned add handling for any other method and of course return whether
the requested method was known or not.
request The HTTP requestresponse The HTTP responsetrue if the requested method (request.getMethod())
is known. Otherwise false is returned.javax.servlet.ServletException Forwarded from any of the dispatched methodsjava.io.IOException Forwarded from any of the dispatched methodsrequest The HTTP request from which the method and protocol values
are extracted to build the appropriate message.response The HTTP response to which the error status is sent.java.io.IOException Thrown if the status cannot be sent to the client.service(javax.servlet.ServletRequest,javax.servlet.ServletResponse) method to
handle the HTTP request. This implementation calls the
mayService(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse) method and
depedending on its return value call the
doGeneric(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse) method. If
the mayService(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse) method
can handle the request, the
doGeneric(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse) method is not
called otherwise it is called.
Implementations of this class should not generally overwrite this method.
Rather the
method should be overwritten to add support for more HTTP methods.
mayService(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse)
request The HTTP requestresponse The HTTP responsejavax.servlet.ServletException Forwarded from the
mayService(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse)
or
doGeneric(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse)
methods.java.io.IOException Forwarded from the
mayService(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse)
or
doGeneric(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse)
methods.service(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse)
method if the request is a HTTP request.
Implementations of this class will not generally overwrite this method.
req The Servlet requestres The Servlet responsejavax.servlet.ServletException If the request is not a HTTP request or
forwarded from the
service(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse)
called.java.io.IOException Forwarded from the
service(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse)
called.doOptions(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse) to calculate
the value of the Allow header sent as the response to the HTTP
OPTIONS request.
This base class implementation checks whether any doXXX methods exist for GET and HEAD and returns the list of methods supported found. The list returned always includes the HTTP OPTIONS and TRACE methods.
Implementations of this class may overwrite this method check for more
methods supported by the extension (generally the same list as used in
the method).
This base class implementation should always be called to make sure the
default HTTP methods are included in the list.
mayService(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse)
declaredMethods The public and protected methods declared in the
extension of this class.StringBuffer containing the list of HTTP methods
supported.doOptions(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse) method to
find the methods to be checked by the
getAllowedRequestMethods(java.util.Map) method. Note, that only extension
classes of this class are considered to be sure to not account for the
default implementations of the doXXX methods in this class.
c The Class to get the declared methods fromsetContentLength()