Class Feature
- java.lang.Object
-
- org.apache.jackrabbit.oak.spi.toggle.Feature
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public final class Feature extends Object implements Closeable
A feature toggle to control new functionality. The default state of a feature isfalseand can be controlled by third party code discoveringFeatureToggles on theWhiteboard. Every feature is linked to a feature toggle and allows to control the state of the feature toggle viaFeatureToggle.setEnabled(boolean). Creating a new feature involves registering a feature toggle on theWhiteboardand potentially comes with some overhead (e.g. when the whiteboard is based on OSGi). Therefore, client code should not create a new feature, check the state and then immediately release/close it again. Instead a feature should be acquired initially, checked at runtime whenever needed and finally released when the client component is destroyed.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Releases resources for this feature toggle.booleanisEnabled()static FeaturenewFeature(String name, Whiteboard whiteboard)Creates a newFeaturewith the given name and registers the correspondingFeatureToggleon theWhiteboard.
-
-
-
Method Detail
-
newFeature
public static Feature newFeature(String name, Whiteboard whiteboard)
Creates a newFeaturewith the given name and registers the correspondingFeatureToggleon theWhiteboard. Client code must callclose()when the toggle is not used anymore.- Parameters:
name- the name of the feature toggle.whiteboard- the whiteboard where to register the feature toggle.- Returns:
- the feature toggle.
-
isEnabled
public boolean isEnabled()
- Returns:
- the current state of this feature.
-
close
public void close()
Releases resources for this feature toggle.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-