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 isfalse
and can be controlled by third party code discoveringFeatureToggle
s 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 theWhiteboard
and 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 void
close()
Releases resources for this feature toggle.boolean
isEnabled()
static Feature
newFeature(String name, Whiteboard whiteboard)
Creates a newFeature
with the given name and registers the correspondingFeatureToggle
on theWhiteboard
.
-
-
-
Method Detail
-
newFeature
public static Feature newFeature(String name, Whiteboard whiteboard)
Creates a newFeature
with the given name and registers the correspondingFeatureToggle
on 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
-