ronx
ronx

Reputation: 89

Restricting javax.servlet.Filter to specific URL pattern

I'm trying to implement a Filter for a project in Adobe CQ 5.6.1. Seems nifty to be used for doing some, say, authentication stuff for each page that gets displayed.

I've read up on the documentation on Filters and I've coded my annotations this way:

@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've compiled my code and looked up the logs, but somehow, it doesn't seem to get filtered for that specific path indicated in the sling.filter.pattern. I don't seem to find much samples on how to implement this so I'm somewhat in the dark about this feature. What I'm sure of is I don't want this Filter to run on every URL that gets loaded.

Any leads would be appreciated. Thanks!

Upvotes: 3

Views: 3301

Answers (1)

Bertrand Delacretaz
Bertrand Delacretaz

Reputation: 6100

As mentioned in the question's comments, the sling.filter.pattern service property on Filters is only supported with V2.4.0 and later of the the org.apache.sling.engine bundle. I have updated the docs at http://sling.apache.org/documentation/the-sling-engine/filters.html to mention this.

Upvotes: 2

Related Questions