Interface ServletResolver
ServletResolver defines the API for a service capable of
resolving jakarta.servlet.Servlet instances to handle the
processing of a request or resource.
Applications of the Sling Framework generally do not need the servlet
resolver as resolution of the servlets to process requests and sub-requests
through a RequestDispatcher is handled by the Sling Framework.
-
Method Summary
Modifier and TypeMethodDescription@Nullable jakarta.servlet.ServletResolves ajakarta.servlet.Servletwhoseservicemethod may be used to handle a request.@Nullable jakarta.servlet.Servletresolve(@NotNull ResourceResolver resolver, @NotNull String scriptName) Resolves ajakarta.servlet.Servletwhoseservicemethod may be used to handle a request.@Nullable jakarta.servlet.Servletresolve(@NotNull SlingJakartaHttpServletRequest request) Resolves ajakarta.servlet.Servletwhoseservicemethod may be used to handle the givenrequest.javax.servlet.ServletresolveServlet(@NotNull Resource resource, @NotNull String scriptName) Deprecated.javax.servlet.ServletresolveServlet(@NotNull ResourceResolver resolver, @NotNull String scriptName) Deprecated.Useresolve(ResourceResolver, String)instead.javax.servlet.ServletresolveServlet(SlingHttpServletRequest request) Deprecated.Useresolve(SlingJakartaHttpServletRequest)instead.
-
Method Details
-
resolve
@Nullable @Nullable jakarta.servlet.Servlet resolve(@NotNull @NotNull SlingJakartaHttpServletRequest request) Resolves ajakarta.servlet.Servletwhoseservicemethod may be used to handle the givenrequest.The returned servlet must be assumed to be initialized and ready to run. That is, the
initnor thedestroymethods must NOT be called on the returned servlet.This method must not return a
Servletinstance implementing theJakartaOptingServletinterface and returningfalsewhen theJakartaOptingServlet.accepts(SlingJakartaHttpServletRequest)method is called.- Parameters:
request- TheSlingJakartaHttpServletRequestobject used to drive selection of the servlet.- Returns:
- The servlet whose
servicemethod may be called to handle the request. Might benull. - Throws:
SlingException- Is thrown if an error occurs while trying to find an appropriate servlet to handle the request.NullPointerException- Ifrequestis null.- Since:
- 2.5.0
-
resolve
@Nullable @Nullable jakarta.servlet.Servlet resolve(@NotNull @NotNull Resource resource, @NotNull @NotNull String scriptName) Resolves ajakarta.servlet.Servletwhoseservicemethod may be used to handle a request.The returned servlet must be assumed to be initialized and ready to run. That is, the
initnor thedestroymethods must NOT be called on the returned servlet.This method skips all
OptingServlets as there is no request object available. Basically this method searches a script with thescriptNamefor the resource type defined by theresource.- Parameters:
resource- TheResourceobject used to drive selection of the servlet.scriptName- The name of the script - the script might have an extension. In this case only a script with the matching extension is used.- Returns:
- The servlet whose
servicemethod may be called to handle the request. Might benull. - Throws:
SlingException- Is thrown if an error occurs while trying to find an appropriate servlet to handle the request or if no servlet could be resolved to handle the request.IllegalArgumentException- Ifresourceis null.- Since:
- 2.1 (Sling API Bundle 2.1.0), 2.5.0
-
resolve
@Nullable @Nullable jakarta.servlet.Servlet resolve(@NotNull @NotNull ResourceResolver resolver, @NotNull @NotNull String scriptName) Resolves ajakarta.servlet.Servletwhoseservicemethod may be used to handle a request.The returned servlet must be assumed to be initialized and ready to run. That is, the
initnor thedestroymethods must NOT be called on the returned servlet.This method skips all
OptingServlets as there is no request object available. Basically this method searches a script with thescriptName- Parameters:
resolver- TheResourceResolverobject used to drive selection of the servlet.scriptName- The name of the script - the script might have an extension. In this case only a script with the matching extension is used.- Returns:
- The servlet whose
servicemethod may be called to handle the request. Might benull. - Throws:
SlingException- Is thrown if an error occurs while trying to find an appropriate servlet to handle the request.IllegalArgumentException- Ifresolveris null.- Since:
- 2.5.0
-
resolveServlet
@Deprecated @Nullable javax.servlet.Servlet resolveServlet(@NotNull SlingHttpServletRequest request) Deprecated.Useresolve(SlingJakartaHttpServletRequest)instead.Resolves ajavax.servlet.Servletwhoseservicemethod may be used to handle the givenrequest.The returned servlet must be assumed to be initialized and ready to run. That is, the
initnor thedestroymethods must NOT be called on the returned servlet.This method must not return a
Servletinstance implementing theOptingServletinterface and returningfalsewhen theOptingServlet.accepts(org.apache.sling.api.SlingHttpServletRequest)method is called.- Parameters:
request- TheSlingHttpServletRequestobject used to drive selection of the servlet.- Returns:
- The servlet whose
servicemethod may be called to handle the request. Might benull. - Throws:
SlingException- Is thrown if an error occurs while trying to find an appropriate servlet to handle the request.NullPointerException- Ifrequestis null.
-
resolveServlet
@Deprecated @Nullable javax.servlet.Servlet resolveServlet(@NotNull @NotNull Resource resource, @NotNull @NotNull String scriptName) Deprecated.Useresolve(Resource, String)instead.Resolves ajavax.servlet.Servletwhoseservicemethod may be used to handle a request.The returned servlet must be assumed to be initialized and ready to run. That is, the
initnor thedestroymethods must NOT be called on the returned servlet.This method skips all
OptingServlets as there is no request object available. Basically this method searches a script with thescriptNamefor the resource type defined by theresource.- Parameters:
resource- TheResourceobject used to drive selection of the servlet.scriptName- The name of the script - the script might have an extension. In this case only a script with the matching extension is used.- Returns:
- The servlet whose
servicemethod may be called to handle the request. Might benull. - Throws:
SlingException- Is thrown if an error occurs while trying to find an appropriate servlet to handle the request or if no servlet could be resolved to handle the request.IllegalArgumentException- Ifresourceis null.- Since:
- 2.1 (Sling API Bundle 2.1.0)
-
resolveServlet
@Deprecated @Nullable javax.servlet.Servlet resolveServlet(@NotNull @NotNull ResourceResolver resolver, @NotNull @NotNull String scriptName) Deprecated.Useresolve(ResourceResolver, String)instead.Resolves ajavax.servlet.Servletwhoseservicemethod may be used to handle a request.The returned servlet must be assumed to be initialized and ready to run. That is, the
initnor thedestroymethods must NOT be called on the returned servlet.This method skips all
OptingServlets as there is no request object available. Basically this method searches a script with thescriptName- Parameters:
resolver- TheResourceResolverobject used to drive selection of the servlet.scriptName- The name of the script - the script might have an extension. In this case only a script with the matching extension is used.- Returns:
- The servlet whose
servicemethod may be called to handle the request. Might benull. - Throws:
SlingException- Is thrown if an error occurs while trying to find an appropriate servlet to handle the request.IllegalArgumentException- Ifresolveris null.- Since:
- 2.1 (Sling API Bundle 2.1.0)
-
resolve(Resource, String)instead.