Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

I have 2 filters and they are running in the wrong order

Avatar

Level 2

I have built 2 filters, and wanted them to run in a specific order so set the sercice.ranking to get them in the right order.

 

Every piece of documentation says that they go in service.ranking order i.e. lowest first, I have tried to do this and even done it in the opposite order and one service still runs before the other.

 

The code for the mapping is

Service 1: (should be first, runs last)

@component(service = Filter.class, property = {

"sling.filter.scope=REQUEST",

"sling.filter.methods=GET",

"sling.filter.extensions=html",

"sling.filter.pattern=/content/.*",

"service.ranking=200"

})

@ServiceDescription("Dynamic Fragment Rendering Filter with HTTP Transfer")

public class DynamicFragmentFilter implements Filter {

 

Second one (should be last, runs first)

@component(service = Filter.class, property = {

"sling.filter.scope=REQUEST",

"sling.filter.methods=GET",

"sling.filter.extensions=html",

"sling.filter.pattern=/content/.*",

"service.ranking=-1500" // Lower ranking to run after other resource resolvers

})

@ServiceDescription("Custom 404 Filter with Inherited Error Page Lookup")

public class Custom404Filter implements Filter {

 

even changing the service.ranking so they are opposite they still run in the same order.

0 Replies