Servlet Resource Provider
A service listener org.apache.sling.servlets.resolver.internal.SlingServletResolver listens for the OSGi services implementing javax.servlet.Servlet interface and registers its reference.When a request hits the server, this SlingServletResolver kicks in to execute its sling script resolution procedure to choose the right servlet to respond to the request.
Each individual servlet will have a dedicated service instance of ServletResourceProvider associated with it, which will provide ServletResources in the resource tree, based on the servlet's registration properties.
The actual resource path of such resources differs for servlets registered by type and those registered by path:
Servlet registered by
|
Full Resource Path
|
Path
|
(given path).servlet
|
ResourceType
|
for each selector, extension and method combination one resource with path resource type[/[<selector with separator '/'>.][extension][method]].servlet'.
|
The resources expose the following properties:
Property Name
|
Description
|
sling:resourceType
|
The resource type to which the servlet is registered. It is equal to the absolute resource path.
|
sling:resourceSuperType
|
The resource superType. Is sling/bundle/resource if not explicitly set.
|
servletName
|
The name of the servlet.
|
servletClass
|
The fully-qualified class name of the underlying servlet.
|
Reference: Servlets and Scripts
Conclusion
In this short theoretical post, we discussed the details of a Servlet Resource Provider. You can find the complete code on my GitHub.
No comments:
Post a Comment
If you have any doubts or questions, please let us know.