Restricting javax.servlet.Filter to specific url pattern
I am trying to implement a filter for a project in Adobe CQ 5.6.1. It seems nifty so that it can be used to do some, say authentication, for every page that is rendered.
I read the Filters documentation and I coded my annotations like this:
@SlingFilter(
label = "Filter implementation",
metatype = true,
generateComponent = true,
generateService = true,
order = 1,
scope = SlingFilterScope.REQUEST
)
@Properties({
@Property(name="service.description", value="A Filter"),
@Property(name="sling.filter.pattern", value="/some/path")
})
I compiled my code and looked at the logs, but somehow it doesn't seem to be filtered for that specific path specified in the sling.filter.pattern file. I didn't seem to find many examples of how to implement this, so I'm a little in the dark about this feature. I'm pretty sure I don't want this filter to run on every URL that I load.
Any findings would be appreciated. Thank!
source to share
As mentioned in the comments on the question, the service property sling.filter.pattern
for filters is only supported with V2.4.0 and later versions of the package org.apache.sling.engine
. I've updated the docs at http://sling.apache.org/documentation/the-sling-engine/filters.html to mention this.
source to share