Package com.day.cq.commons.servlets
Class NonExistingDispatcherServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- com.day.cq.commons.servlets.NonExistingDispatcherServlet
-
- All Implemented Interfaces:
java.io.Serializable
,Servlet
,ServletConfig
,OptingServlet
@SlingServlet(paths={"/apps/sling/nonexisting/GET.servlet","/apps/sling/nonexisting/POST.servlet","/apps/sling/nonexisting/PUT.servlet"}) @Reference(name="Servlet", referenceInterface=NonExistingResourceServlet.class, policy=DYNAMIC, cardinality=OPTIONAL_MULTIPLE) public class NonExistingDispatcherServlet extends GenericServlet implements OptingServlet
NonExistingDispatcherServlet is a solution to dispatch the sling:nonexisting resource type based on dynamic acceptance. With standard Sling it is only possible to register a single servlet for each HTTP method on the nonexisting resource.Please note: This is a temporary solution until Sling provides a built-in mechanism for this use case. Not to be used by client implementations!
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description NonExistingDispatcherServlet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accepts(SlingHttpServletRequest request)
Examines the request, and returntrue
if this servlet is willing to handle the request.void
service(ServletRequest request, ServletResponse res)
Called by the servlet container to allow the servlet to respond to a request.-
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.servlet.Servlet
destroy, getServletConfig, getServletInfo, init
-
-
-
-
Method Detail
-
accepts
public boolean accepts(SlingHttpServletRequest request)
Description copied from interface:OptingServlet
Examines the request, and returntrue
if this servlet is willing to handle the request. Iffalse
is returned, the request will be ignored by this servlet, and may be handled by other servlets.- Specified by:
accepts
in interfaceOptingServlet
- Parameters:
request
- The request to examine- Returns:
true
if this servlet will handle the request,false
otherwise
-
service
public void service(ServletRequest request, ServletResponse res) throws ServletException, java.io.IOException
Description copied from class:GenericServlet
Called by the servlet container to allow the servlet to respond to a request. SeeServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
.This method is declared abstract so subclasses, such as
HttpServlet
, must override it.- Specified by:
service
in interfaceServlet
- Specified by:
service
in classGenericServlet
- Parameters:
request
- theServletRequest
object that contains the client's requestres
- theServletResponse
object that will contain the servlet's response- Throws:
ServletException
- if an exception occurs that interferes with the servlet's normal operation occurredjava.io.IOException
- if an input or output exception occurs
-
-