Skip to content

Repository files navigation

DevCycle Java Server SDK

Welcome to the DevCycle Java Server SDK, providing feature flag functionality via Local Bucketing or Cloud Bucket through the DevCycle Bucketing API.

Requirements

This version of the DevCycle SDK works with Java 11 and above.

Using the Java SDK library requires Maven or Gradle >= 7.6+ to be installed.

An x86_64 or aarch64 JDK is required for Local Bucketing with the DevCycle Java SDK.

Currently Supported Platforms are:

OSArch
Linux (ELF)x86_64
Linux (ELF)aarch64
Mac OSx86_64
Mac OSaarch64
Windowsx86_64

In addition, the environment must support GLIBC v2.16 or higher. You can use the following command to check your GLIBC version:

ldd --version

Installation

Gradle

You can use the SDK in your Gradle project by adding the following to build.gradle:

implementation("com.devcycle:java-server-sdk:2.9.5")

Maven

You can use the SDK in your Maven project by adding the following to your pom.xml:

<dependency>
<groupId>com.devcycle</groupId>
<artifactId>java-server-sdk</artifactId>
<version>2.9.5</version>
<scope>compile</scope>
</dependency>

DNS Caching

The JVM, by default, caches DNS for infinity. DevCycle servers are load balanced and dynamic. To address this concern, setting the DNS cache TTL to a short duration is recommended. The TTL is controlled by this security setting networkaddress.cache.ttl. Recommended settings and how to configure them can be found here.

Getting Started

To use the DevCycle Java SDK, initialize a client object.

Cloud:

importcom.devcycle.sdk.server.cloud.api.DevCycleCloudClient;
publicclassMyClass {
privateDevCycleCloudClientdvcCloudClient;
publicMyClass() {
dvcCloudClient = newDevCycleCloudClient("DEVCYCLE_SERVER_SDK_KEY");
}
}

Local:

importcom.devcycle.sdk.server.local.api.DevCycleLocalClient;
publicclassMyClass {
privateDevCycleLocalClientdvcLocalClient;
publicMyClass() {
dvcLocalClient = newDevCycleLocalClient("DEVCYCLE_SERVER_SDK_KEY");
}
}

OpenFeature Support

This SDK provides an implementation of the OpenFeature Provider interface. Use the getOpenFeatureProvider() method on the DevCycle SDK client to obtain a provider for OpenFeature.

DevCycleLocalClientdevCycleClient = newDevCycleLocalClient("DEVCYCLE_SERVER_SDK_KEY", options);
OpenFeatureAPIapi = OpenFeatureAPI.getInstance();
api.setProvider(devCycleClient.getOpenFeatureProvider());

You can find additional instructions on how to use it here: DevCycle Java SDK OpenFeature Provider

Usage

To find usage documentation, visit our docs for Local Bucketing and Cloud Bucketing

Logging

The DevCycle SDK logs to stdout by default and does not require any specific logging package. To integrate with your own logging system, such as Java Logging or SLF4J, you can create a wrapper that implements the IDevCycleLogger interface. Then you can set the logger into the Java Server SDK setting the Custom Logger property in the options object used to initialize the client.

// Create your logging wrapperIDevCycleLoggerloggingWrapper = newIDevCycleLogger() {
@Overridepublicvoiddebug(Stringmessage) {
// Your logging implementation here
}
@Overridepublicvoidinfo(Stringmessage) {
// Your logging implementation here
}
@Overridepublicvoidwarning(Stringmessage) {
// Your logging implementation here
}
@Overridepublicvoiderror(Stringmessage) {
// Your logging implementation here
}
@Overridepublicvoiderror(Stringmessage, Throwablethrowable) {
// Your logging implementation here
}
};
// Set the logger in the options before creating the DevCycleLocalClientDevCycleLocalOptionsoptions = DevCycleLocalOptions.builder().customLogger(loggingWrapper).build();
DevCycleLocalClientdvcClient = newDevCycleLocalClient("DEVCYCLE_SERVER_SDK_KEY", options);
// Or for DevCycleCloudClientDevCycleCloudOptionsoptions = DevCycleCloudOptions.builder().customLogger(loggingWrapper).build();
DevCycleCloudClientdvcClient = newDevCycleCloudClient("DEVCYCLE_SERVER_SDK_KEY", options);

You can also disable all logging by setting the custom logger to new SimpleDevCycleLogger(SimpleDevCycleLogger.Level.OFF).

Releases

Packages

Used by

Contributors

Languages