1616import lombok .extern .slf4j .Slf4j ;
1717
1818/**
19- * A global singleton which holds base configuration for the OpenFeature
20- * library.
21- * Configuration here will be shared across all {@link Client}s.
19+ * Holds base configuration for the OpenFeature library.
20+ *
21+ * <p>Most applications should use the global singleton via {@link #getInstance()}; configuration
22+ * there is shared across all {@link Client}s. For dependency-injection frameworks, testing, or
23+ * multi-tenant scenarios that need fully independent state (providers, hooks, evaluation context,
24+ * event handlers, transaction context propagators), instantiate a new instance directly with
25+ * {@code new OpenFeatureAPI()}.
26+ *
27+ * @apiNote Isolated API instances (per spec section 1.8) are experimental and subject to change.
28+ * @see <a href="https://openfeature.dev/specification/sections/flag-evaluation#18-isolated-api-instances">
29+ * Spec §1.8 — Isolated API Instances</a>
2230 */
2331@ Slf4j
2432@ SuppressWarnings ("PMD.UnusedLocalVariable" )
@@ -40,6 +48,14 @@ public class OpenFeatureAPI implements EventBus<OpenFeatureAPI> {
4048 private final AtomicReference <EvaluationContext > evaluationContext = new AtomicReference <>();
4149 private TransactionContextPropagator transactionContextPropagator ;
4250
51+ /**
52+ * Creates a new, independent {@link OpenFeatureAPI} instance with fully isolated state
53+ * (providers, hooks, evaluation context, event handlers, transaction context propagators).
54+ *
55+ * <p>For typical usage, prefer the global singleton via {@link #getInstance()}.
56+ *
57+ * @apiNote Isolated API instances (per spec section 1.8) are experimental and subject to change.
58+ */
4359 public OpenFeatureAPI () {
4460 this (new AutoCloseableReentrantReadWriteLock ());
4561 }
0 commit comments