Package com.day.cq.commons.servlets
Class NonExistingDispatcherServlet
java.lang.Object
javax.servlet.GenericServlet
com.day.cq.commons.servlets.NonExistingDispatcherServlet
- All Implemented Interfaces:
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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaccepts(SlingHttpServletRequest request) Examines the request, and returntrueif this servlet is willing to handle the request.voidservice(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, logMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.servlet.Servlet
destroy, getServletConfig, getServletInfo, init
-
Constructor Details
-
NonExistingDispatcherServlet
public NonExistingDispatcherServlet()
-
-
Method Details
-
accepts
Description copied from interface:OptingServletExamines the request, and returntrueif this servlet is willing to handle the request. Iffalseis returned, the request will be ignored by this servlet, and may be handled by other servlets.- Specified by:
acceptsin interfaceOptingServlet- Parameters:
request- The request to examine- Returns:
trueif this servlet will handle the request,falseotherwise
-
service
public void service(ServletRequest request, ServletResponse res) throws ServletException, IOException Description copied from class:GenericServletCalled 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:
servicein interfaceServlet- Specified by:
servicein classGenericServlet- Parameters:
request- theServletRequestobject that contains the client's requestres- theServletResponseobject that will contain the servlet's response- Throws:
ServletException- if an exception occurs that interferes with the servlet's normal operation occurredIOException- if an input or output exception occurs
-