I am trying to add some functionality to json processing for some nodes. So I wrote custom servlet extended from SlingSafeMethodsServlet which I need to be executed when user makes GET for the following url : /data/events/any_sequence/any_sequence.json or /data/events/any_sequence/any_sequence.infinity.json or for example /data/events/any_sequence/any_sequence.2.json where any_sequence of course means any valid sequence of symbols.
The problem is that I cannot find in the sling docs how to map this template like urls.
I’ve been trying to set properties like this:
@Component
@Service
@Properties({
@Property(name = "sling.servlet.resourceTypes", value = "data/events/-/-"),
@Property(name = "sling.servlet.extensions", value = "json"),
@Property(name = "sling.servlet.methods", value = "GET"),
@Property(name = "service.description", value = "JSON advanced renderer")
})
But it didn’t help. I checked felix console and found out that my service had started and running, so the problem is how to set url mappings. So my question is how to set url mapping in my case to invoke doGet of my custom servlet ?
Thanks.
As far as I understand CQ5 does not provide ability to map custom servlets on wildcard urls. The only way to accomplish goal similiar to one I needed is to use some unique for this servlet selector like this:
This code means that if I’ll try to make GET on some node with
*.advanced.jsonselector and extension then request will be forwarded to my custom servlet.See http://apache-sling.73963.n3.nabble.com/Register-servlet-for-subtree-td84106.html