Rollout.io

Rollout.io Java SDK

Overview

The Rollout.io Java SDK is an enterprise-grade, high-performance library designed for modern server-side Java and Spring Boot environments. It provides real-time feature flag evaluation with production-grade telemetry, built utilizing the native Java 11+ HttpClient for optimal throughput and minimal dependency overhead.

Core Capabilities

Installation

Add the JitPack Repository

Since this SDK is distributed via JitPack, add the repository to your pom.xml:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Add the Dependency

Include the SDK artifact in your pom.xml:

<dependencies>
    <dependency>
        <groupId>com.github.TechParaglide</groupId>
        <artifactId>Rollout.io</artifactId>
        <version>5.0.5</version>
    </dependency>
</dependencies>

Professional Implementation Guide

For robust integration in Spring Boot or standard Java applications, we highly recommend utilizing a Singleton or Bean injection pattern to ensure the SDK is instantiated only once per application lifecycle.

SDK Initialization Example

import com.rollout.io.sdk.RolloutClient;
import com.rollout.io.sdk.RolloutConfig;
import java.util.HashMap;
import java.util.Map;

public class RolloutService {
    private RolloutClient client;

    public void initializeSdk(String userId) {
        try {
            client = new RolloutClient();
            RolloutConfig config = new RolloutConfig(
                "YOUR_SDK_KEY",
                userId,
                "http://rollout.paraglide.in/gateway" // Live Production Gateway
            );
            
            // Optional: Configure contextual attributes for advanced targeting
            Map<String, Object> attributes = new HashMap<>();
            attributes.put("role", "admin");
            attributes.put("plan", "premium");
            config.setAttributes(attributes);

            // Optional: Set polling interval in milliseconds (e.g., 30s)
            config.setRefreshInterval(30000); 
            
            client.init(config);
            System.out.println("Rollout.io SDK initialized successfully.");
        } catch (Exception e) {
            System.err.println("Rollout.io Initialization failed: " + e.getMessage());
        }
    }

    public RolloutClient getClient() {
        return client;
    }
}

API Reference

The SDK exposes the RolloutClient instance with the following public methods:

init(RolloutConfig config)

Initializes the SDK and fetches the initial configuration state from the Control Plane. This must be called before evaluating any flags.

Parameters (RolloutConfig object):

Returns: void (Throws Exception if network failure occurs during initialization).

getFlag(String key, boolean defaultValue)

Retrieves the evaluated boolean value of a feature flag. This operates synchronously by reading from the internal cache populated during initialization. It also automatically dispatches telemetry to the Control Plane.

Parameters:

Returns:

Example:

boolean isBannerEnabled = client.getFlag("hero-banner-v2", false);

if (isBannerEnabled) {
    // Render the new hero banner feature
} else {
    // Render the default fallback experience
}

getFlagObject(String key, Object defaultValue)

Retrieves the evaluated complex object value (JSON/String/Number) of a feature flag.

Parameters:

Returns:

Example:

Object rateLimitConfig = client.getFlagObject("api-rate-limit", 100);
int currentLimit = (Integer) rateLimitConfig;

onUpdate(Consumer<Map<String, Object>> callback)

Subscribes a listener that triggers whenever the remote configuration state changes. This is highly useful for reacting to live configuration updates fetched by the polling mechanism.

Parameters:

Example:

client.onUpdate(flags -> {
    System.out.println("Remote configuration state has been updated: " + flags.size() + " flags received.");
    // Invalidate local application caches or trigger state changes
});

destroy()

Cleans up the SDK instance. It stops all active background polling ScheduledExecutorService threads and clears event listeners to prevent memory leaks. Use this during bean destruction or application teardown.

Parameters: None

Example:

// Spring Boot PreDestroy or application shutdown hook
public void teardownApplication() {
    System.out.println("Shutting down Rollout.io SDK connections...");
    client.destroy();
}

Architecture and Directory Structure

Troubleshooting and Debugging


(C) 2026 Rollout.io Engineering Team