Hi all,

I need to introduce a feature flag to sling code.
I have seen
https://sling.apache.org/documentation/the-sling-engine/featureflags.html
but I think we can do this simpler.

In OSGi R8 there is
https://docs.osgi.org/specification/osgi.core/8.0.0/service.condition.html .
This is ideal for feature toggles.

I propose that we expose feature toggles using a prefix + the toggle name.
So for example it could be "org.apache.sling.toggle.FT-SLING-1234".

I have already experimented with this and it seems feasible.

Code using this can look like this:

@Activate
public MyComponent(
            @Nullable
            @Reference(target =
"(osgi.condition.id=org.apache.sling.toggle.FT_SLING-1234)",
cardinality = ReferenceCardinality.OPTIONAL, policyOption =
ReferencePolicyOption.GREEDY)
            Condition myToggle
            ) {
     boolean myToggleActive = myToggle != null;
}

You can also make the start of a DS component depend on the toggle. (See
examples in the spec).

What do you think?

Christian

-- 
-- 
Christian Schneider
http://www.liquid-reality.de

Computer Scientist
http://www.adobe.com

Reply via email to