Class GBFeaturesRepository

java.lang.Object
growthbook.sdk.java.GBFeaturesRepository

public class GBFeaturesRepository extends Object
This class can be created with its `builder()` or constructor. It will fetch the features from the endpoint provided. Initialize with initialize() Get the features JSON with getFeaturesJson(). You would provide the features JSON when creating the GBContext
  • Constructor Details

    • GBFeaturesRepository

      public GBFeaturesRepository(String endpoint, @Nullable String encryptionKey, @Nullable Integer ttlSeconds)
      Create a new GBFeaturesRepository
      Parameters:
      endpoint - SDK Endpoint URL
      encryptionKey - optional key for decrypting encrypted payload
      ttlSeconds - How often the cache should be invalidated (default: 60)
  • Method Details

    • getFeaturesJson

      public String getFeaturesJson()
    • onFeaturesRefresh

      public void onFeaturesRefresh(FeatureRefreshCallback callback)
      Subscribe to feature refresh events This callback is called when the features are successfully refreshed. This is called even if the features have not changed. This will not be called if fetching the features results in a failure.
      Parameters:
      callback - This callback will be called when features are refreshed
    • clearCallbacks

      public void clearCallbacks()
    • initialize

      public void initialize() throws FeatureFetchException
      Throws:
      FeatureFetchException