CQ5.5 order standard HTTP filters deployed as OSGI components

删除回忆录丶 提交于 2019-12-12 03:02:57

问题


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.


回答1:


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)




回答2:


You need to add a filter.order attribute to your service:

@Property(name="filter.order",intValue=-2500)

The lower the value, the further ahead in the chain the filter will be placed.



来源:https://stackoverflow.com/questions/15775044/cq5-5-order-standard-http-filters-deployed-as-osgi-components

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!