In CQ5.5 How I can order 2 standard HTTP Filters deployed as OSGI components?
The issue is that the 2 filters have to run in order where FilterA should run first and then FilterB in sequence.
How I can order my 2 filters in sequence?
Do you know if there is any OSGI or SCR property with which I can order the 2 filter so that one should run after another?
For example:
Filter A
@Component
@Service
@org.apache.felix.scr.annotations.Properties({
@Property(name = "pattern", value = "/.*"),
@Property(name = Constants.SERVICE_RANKING, intValue = 99999, propertyPrivate = false)
})
public class FilterA implements implements javax.servlet.Filter {
}
FilterB
@Component
@Service
@org.apache.felix.scr.annotations.Properties({
@Property(name = "pattern", value = "/.*"),
@Property(name = Constants.SERVICE_RANKING, intValue = 100000, propertyPrivate = false)
})
public class FilterB implements implements javax.servlet.Filter {
}
I would like to run FilterA first and then FilterB.
If I deploy the above filters as OSGI bundles on CQ5.5 I only see FilterB is triggered on the HTTP White board console. I do not see FilterA being even invoked during my CQ5.5 login request flow.
Thanks.
You need to add a filter.order attribute to your service:
The lower the value, the further ahead in the chain the filter will be placed.
Check http://sling.apache.org/site/filters.html Service Ranking is what you're looking for. Also note on sling/cq5 you can see which filters are active and their ranking by looking /system/console/config and Sling Servlet Filters.
Also see filter-scope and the changes made to introduce pattern based scopes (SLING-1213, SLING-1734)