0

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?

Archit Arora
  • 2,508
  • 7
  • 43
  • 69
  • 1
    Unsure of having it disabled, but you can have a [Sling Feature Flag](https://sling.apache.org/documentation/the-sling-engine/featureflags.html) to check whether the filter needs to execute or not. Sample implementation blogpost - https://www.albinsblog.com/2020/08/sling-feature-flags-for-continuous-integration-in-aem-feature-toggles-in-aem.html#.X0crfGziuUk – rakhi4110 Aug 27 '20 at 03:42
  • @rakhi4110 How about providing an invalid value to the scope as mentioned here - https://techrevel.blog/2019/07/04/ds-annotations-sling-filter/ Not sure if its the best practice – Archit Arora Aug 27 '20 at 03:56
  • 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 Aug 28 '20 at 00:49

1 Answers1

1

You can disable it by using ACS commons component disabler: https://adobe-consulting-services.github.io/acs-aem-commons/features/osgi-disablers/component-disabler/index.html

Pakira
  • 1,951
  • 3
  • 25
  • 54