reschke commented on PR #2947:
URL: https://github.com/apache/jackrabbit-oak/pull/2947#issuecomment-4691611965

   @mreutegg - something like this...?
   ```
   
       private static Feature 
internalNewFeatureWithSystemPropertyDefault(String name, Whiteboard whiteboard, 
boolean withSysPropDefault) {
           // by default the initial value is false, but it can be overridden 
by a system property
           AtomicBoolean value = withSysPropDefault ? new AtomicBoolean(
                   SystemPropertySupplier.create("oak-feature." + name, false).
                           loggingTo(LOG).get()) : new AtomicBoolean();
           FeatureToggle adapter = new FeatureToggle(name, value);
           return new Feature(value, whiteboard.register(
                   FeatureToggle.class, adapter, Collections.emptyMap()));
       }
   
       /**
        * Creates a new {@link Feature} with the given name and registers the
        * corresponding {@link FeatureToggle} on the {@link Whiteboard}.
        * Client code must call {@link Feature#close()} when the toggle is
        * not used anymore.
        *
        * @param name the name of the feature toggle.
        * @param whiteboard the whiteboard where to register the feature toggle.
        * @return the feature toggle.
        */
       public static Feature newFeature(String name, Whiteboard whiteboard) {
           return internalNewFeatureWithSystemPropertyDefault(name, whiteboard, 
false);
       }
   
       /**
        * Same as {@linkplain #newFeature(String, Whiteboard)}m but with the 
initial state provided
        * by a system property, named based on the feature's name.
        */
       public static Feature newFeatureWithSystemPropertyDefault(String name, 
Whiteboard whiteboard) {
           return internalNewFeatureWithSystemPropertyDefault(name, whiteboard, 
true);
       }
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to