|
|
||
|---|---|---|
| .github/workflows | ||
| gradle/wrapper | ||
| lib | ||
| .gitattributes | ||
| .gitignore | ||
| LICENSE | ||
| README.md | ||
| gradlew | ||
| gradlew.bat | ||
| settings.gradle | ||
| spec_finder.py | ||
README.md
OpenFeature SDK for Java
This is the Java implementation of Open Feature. It is intended to be used in server-side contexts and has not been evaluated for use in mobile devices.
Usage
There are a variety flag types that we offer, but Boolean provides the simplest introduction. We can use this SDK to
class MyClass {
// ...
public void myFunction() {
if (client.getBooleanValue("redesign_enabled", false)) {
return render_redesign();
}
return render_normal();
}
// ...
}
Requirements
- Java 11+
Installation
Add it to your build
Maven:
<dependency>
<groupId>dev.openfeature</groupId>
<artifactId>javasdk</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
Gradle:
dependencies {
implementation 'dev.openfeature:javasdk:0.0.1-SNAPSHOT'
}
Configure it
To configure it, you'll need to add a provider to the global singleton OpenFeatureAPI. From there, you can generate a Client which is usable by your code. While you'll likely want a provider for your specific backend, we've provided a NoOpProvider, which simply returns the default passed in.
class MyApp {
public void example(){
OpenFeatureAPI api = OpenFeatureAPI.getInstance();
api.setProvider(new NoOpProvider());
Client client = api.getClient();
// Now use your `client` instance to evaluate some feature flags!
}
}
Contacting us
We hold regular meetings which you can see here.
We are also present on the #openfeature channel in the CNCF slack.
Contributors
Thanks so much to our contributors.
Made with contrib.rocks.