0
votes

I have created a sling filter. Below is a snippet -

@SlingFilter(label = "My filter", description = "Myfilter", metatype = true, generateComponent = true, generateService = true, order = 0, scope = SlingFilterScope.INCLUDE)

public class SlingInoFilter implements Filter { 
}

When I deploy my code, I want this filter to be deployed but in a disabled state. Is this achievable?

1
Unsure of having it disabled, but you can have a Sling Feature Flag to check whether the filter needs to execute or not. Sample implementation blogpost - albinsblog.com/2020/08/… - rakhi4110
@rakhi4110 How about providing an invalid value to the scope as mentioned here - techrevel.blog/2019/07/04/ds-annotations-sling-filter Not sure if its the best practice - Archit Arora
I don't think deploying a code which is wrong on purpose makes since. Because if you want to enable it again you need to do a full deployment for it to use the right scope. Having feature flags provides you the ability to turn it on or off using OSGi configuration avoiding deployments. - rakhi4110

1 Answers