Class Provider
- java.lang.Object
-
- dev.openfeature.sdk.EventProvider
-
- com.launchdarkly.openfeature.serverprovider.Provider
-
- All Implemented Interfaces:
dev.openfeature.sdk.FeatureProvider
public class Provider extends dev.openfeature.sdk.EventProvider
An OpenFeatureFeatureProvider
which enables the use of the LaunchDarkly Server-Side SDK for Java with OpenFeature.import dev.openfeature.sdk.OpenFeatureAPI; public class Main { public static void main(String[] args) { OpenFeatureAPI.getInstance().setProvider(new Provider("fake-key")); // Refer to OpenFeature documentation for getting a client and performing evaluations. } }
-
-
Constructor Summary
Constructors Constructor Description Provider(java.lang.String sdkKey)
Create a provider with the specified SDK and default configuration.Provider(java.lang.String sdkKey, com.launchdarkly.sdk.server.LDConfig config)
Crate a provider with the specified SDK key and configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description dev.openfeature.sdk.ProviderEvaluation<java.lang.Boolean>
getBooleanEvaluation(java.lang.String key, java.lang.Boolean defaultValue, dev.openfeature.sdk.EvaluationContext ctx)
dev.openfeature.sdk.ProviderEvaluation<java.lang.Double>
getDoubleEvaluation(java.lang.String key, java.lang.Double defaultValue, dev.openfeature.sdk.EvaluationContext ctx)
dev.openfeature.sdk.ProviderEvaluation<java.lang.Integer>
getIntegerEvaluation(java.lang.String key, java.lang.Integer defaultValue, dev.openfeature.sdk.EvaluationContext ctx)
com.launchdarkly.sdk.server.interfaces.LDClientInterface
getLdClient()
Get the LaunchDarkly client associated with this provider.dev.openfeature.sdk.Metadata
getMetadata()
dev.openfeature.sdk.ProviderEvaluation<dev.openfeature.sdk.Value>
getObjectEvaluation(java.lang.String key, dev.openfeature.sdk.Value defaultValue, dev.openfeature.sdk.EvaluationContext ctx)
dev.openfeature.sdk.ProviderState
getState()
dev.openfeature.sdk.ProviderEvaluation<java.lang.String>
getStringEvaluation(java.lang.String key, java.lang.String defaultValue, dev.openfeature.sdk.EvaluationContext ctx)
void
initialize(dev.openfeature.sdk.EvaluationContext evaluationContext)
void
shutdown()
-
Methods inherited from class dev.openfeature.sdk.EventProvider
emit, emitProviderConfigurationChanged, emitProviderError, emitProviderReady, emitProviderStale
-
-
-
-
Constructor Detail
-
Provider
public Provider(java.lang.String sdkKey)
Create a provider with the specified SDK and default configuration.If you need to specify any configuration use
Provider(String, LDConfig)
instead.- Parameters:
sdkKey
- the SDK key for your LaunchDarkly environment
-
Provider
public Provider(java.lang.String sdkKey, com.launchdarkly.sdk.server.LDConfig config)
Crate a provider with the specified SDK key and configuration.- Parameters:
sdkKey
- the SDK key for your LaunchDarkly environmentconfig
- a client configuration object
-
-
Method Detail
-
getMetadata
public dev.openfeature.sdk.Metadata getMetadata()
-
getBooleanEvaluation
public dev.openfeature.sdk.ProviderEvaluation<java.lang.Boolean> getBooleanEvaluation(java.lang.String key, java.lang.Boolean defaultValue, dev.openfeature.sdk.EvaluationContext ctx)
-
getStringEvaluation
public dev.openfeature.sdk.ProviderEvaluation<java.lang.String> getStringEvaluation(java.lang.String key, java.lang.String defaultValue, dev.openfeature.sdk.EvaluationContext ctx)
-
getIntegerEvaluation
public dev.openfeature.sdk.ProviderEvaluation<java.lang.Integer> getIntegerEvaluation(java.lang.String key, java.lang.Integer defaultValue, dev.openfeature.sdk.EvaluationContext ctx)
-
getDoubleEvaluation
public dev.openfeature.sdk.ProviderEvaluation<java.lang.Double> getDoubleEvaluation(java.lang.String key, java.lang.Double defaultValue, dev.openfeature.sdk.EvaluationContext ctx)
-
getObjectEvaluation
public dev.openfeature.sdk.ProviderEvaluation<dev.openfeature.sdk.Value> getObjectEvaluation(java.lang.String key, dev.openfeature.sdk.Value defaultValue, dev.openfeature.sdk.EvaluationContext ctx)
-
getState
public dev.openfeature.sdk.ProviderState getState()
- Specified by:
getState
in interfacedev.openfeature.sdk.FeatureProvider
- Specified by:
getState
in classdev.openfeature.sdk.EventProvider
-
initialize
public void initialize(dev.openfeature.sdk.EvaluationContext evaluationContext) throws java.lang.Exception
- Throws:
java.lang.Exception
-
shutdown
public void shutdown()
-
getLdClient
public com.launchdarkly.sdk.server.interfaces.LDClientInterface getLdClient()
Get the LaunchDarkly client associated with this provider.This can be used to access LaunchDarkly features which are not available in OpenFeature.
- Returns:
- the launchdarkly client instance
-
-