Skip to main content

OpenFeature Provider for Java SDK

Overview

The Java OpenFeature ProviderProviders act as a bridge between the Evaluation API and the underlying flag management system. They translate API calls into the format required by the provider, which could be a vendor SDK, a custom REST API, or a local data source. allows your Java applications to integrate with Harness FME using a standardized, vendor-agnostic feature flagging API. This provider implements the OpenFeature specification and bridges the OpenFeature SDK with the Harness FME Java SDK.

This page walks you through installing, configuring, and using the Java OpenFeature provider to evaluate feature flagsA feature flag is a conditional toggle in Harness FME that enables or disables specific functionality without deploying new code. It allows for controlled feature rollouts, A/B testing, and quick rollbacks if issues arise. in your Java applications.

Prerequisites

Before you begin, ensure you have the following:

  • A valid Harness FME SDK key for your project
  • A Java environment running version 11 or later
  • Access to your Maven build configuration

Version compatibility

ComponentMinimum Version
Java11+
split-openfeature-provider-java≥ 1.2.1
OpenFeature Java SDK≥ 1.0.0

Install the provider and dependencies

Add the Harness FME OpenFeature provider dependency to your Maven build configuration.

<dependency>
<groupId>io.split.openfeature</groupId>
<artifactId>split-openfeature-provider</artifactId>
<version>1.2.1</version>
</dependency>

Initialize the provider

You can instantiate and register the provider using your Harness FME SDK key.

import dev.openfeature.sdk.OpenFeatureAPI;
import io.split.openfeature.SplitProvider;

OpenFeatureAPI api = OpenFeatureAPI.getInstance();
api.setProviderAndWait(new SplitProvider("<YOUR_API_KEY>"));

Alternatively, if you want more control or need advanced initialization, you can create a SplitClient and provide it directly:

import dev.openfeature.sdk.OpenFeatureAPI;
import io.split.openfeature.SplitProvider;
import io.split.client.SplitClient;
import io.split.client.SplitClientConfig;
import io.split.client.SplitFactoryBuilder;

OpenFeatureAPI api = OpenFeatureAPI.getInstance();


SplitClientConfig config = SplitClientConfig.builder()
.setBlockUntilReadyTimeout(10000)
.build();
SplitClient splitClient = SplitFactoryBuilder.build("<YOUR_API_KEY>", config).client();
api.setProviderAndWait(new SplitProvider(splitClient));

Construct an evaluation context

Use an evaluation contextThe Evaluation Context holds contextual information used during flag evaluation. It can include static data (like application or host identifiers) and dynamic data (such as a client IP address), which can be passed explicitly or propagated automatically. Static and dynamic values can be merged for richer, more targeted evaluations. with a targeting keyA unique identifier used to target specific users or entities when evaluating feature flags. It helps determine which variation of a flag should be served based on predefined rules and conditions. to pass attributes used for flag targeting. You can include identifiers such as user IDs, email addresses, plan types, and more.=

For example:

Client client = api.getClient("CLIENT_NAME");

EvaluationContext context = new MutableContext("<TARGETING_KEY>");
Boolean boolValue = client.getBooleanValue("boolFlag", false, context);

If the same targeting key is reused across evaluations, set the context at the client or API level:

EvaluationContext context = new MutableContext("<TARGETING_KEY>");
client.setEvaluationContext(context)

Or globally:

EvaluationContext context = new MutableContext("<TARGETING_KEY>");
OpenFeatureAPI.getInstance().setEvaluationContext(context)

Once the context is set at the client or API level, you don’t need to provide it for each evaluation.

Evaluate with details

Use the get*Details(...) APIs to get flag values and metadata (such as variant, reason, error code, and configuration). The FME treatment configuration is returned as a raw JSON string under flagMetadata["config"].

For example:

// boolean/string/number/object all have *Details variants:
FlagEvaluationDetails<String> details =
client.getStringDetails("my-flag", "fallback", ctx);

String jsonConfig = details.getFlagMetadata().getString("config"); // ← Split treatment config

Track events

The FME OpenFeature provider supports tracking user actions or conversion eventsEvents allow your application to respond to changes in provider state or flag configuration, such as readiness changes, errors, or updates to flag values. directly from your Java application.

To enable event tracking, your evaluation context must include the following:

  • A non-empty targetingKey
  • A trafficType (for example, "user" or "account")
  • A non-blank event name

Optionally, you can include a numeric value and additional event properties.

For example:

MutableContext ctx = new MutableContext("user-123");
ctx.add("trafficType", new Value("user"));

TrackingEventDetails details = new MutableTrackingEventDetails(19.99)
.add("plan", new Value("pro"))
.add("coupon", new Value("WELCOME10"));

client.track("checkout.completed", ctx, details);

For more information, see the Harness FME Java OpenFeature Provider GitHub repository.