From 2fd128be498e9dd839483f1920eb5ab74064f3ba Mon Sep 17 00:00:00 2001 From: arifBurakDemiray Date: Mon, 25 Sep 2023 15:53:06 +0300 Subject: [PATCH] feat: irGenerator to cnfig --- .../src/main/java/ly/count/sdk/java/Config.java | 8 ++++++-- .../src/main/java/ly/count/sdk/java/Countly.java | 8 ++++++-- .../java/internal/ImmediateRequestGenerator.java | 5 +++++ .../sdk/java/internal/ImmediateRequestI.java | 2 +- .../count/sdk/java/internal/InternalConfig.java | 3 ++- .../java/ly/count/sdk/java/internal/SDKCore.java | 16 ++++++++++++---- 6 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 sdk-java/src/main/java/ly/count/sdk/java/internal/ImmediateRequestGenerator.java diff --git a/sdk-java/src/main/java/ly/count/sdk/java/Config.java b/sdk-java/src/main/java/ly/count/sdk/java/Config.java index 932766fe4..565790cd1 100644 --- a/sdk-java/src/main/java/ly/count/sdk/java/Config.java +++ b/sdk-java/src/main/java/ly/count/sdk/java/Config.java @@ -12,8 +12,12 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; - -import ly.count.sdk.java.internal.*; +import ly.count.sdk.java.internal.Byteable; +import ly.count.sdk.java.internal.CoreFeature; +import ly.count.sdk.java.internal.Log; +import ly.count.sdk.java.internal.LogCallback; +import ly.count.sdk.java.internal.ModuleBase; +import ly.count.sdk.java.internal.Utils; /** * Countly configuration object. diff --git a/sdk-java/src/main/java/ly/count/sdk/java/Countly.java b/sdk-java/src/main/java/ly/count/sdk/java/Countly.java index 3d26f980c..d337020d6 100644 --- a/sdk-java/src/main/java/ly/count/sdk/java/Countly.java +++ b/sdk-java/src/main/java/ly/count/sdk/java/Countly.java @@ -2,8 +2,12 @@ import java.io.File; import java.util.Map; - -import ly.count.sdk.java.internal.*; +import ly.count.sdk.java.internal.CtxCore; +import ly.count.sdk.java.internal.Device; +import ly.count.sdk.java.internal.InternalConfig; +import ly.count.sdk.java.internal.Log; +import ly.count.sdk.java.internal.ModuleBackendMode; +import ly.count.sdk.java.internal.SDKCore; /** * Main Countly SDK API class. diff --git a/sdk-java/src/main/java/ly/count/sdk/java/internal/ImmediateRequestGenerator.java b/sdk-java/src/main/java/ly/count/sdk/java/internal/ImmediateRequestGenerator.java new file mode 100644 index 000000000..cba56a0c2 --- /dev/null +++ b/sdk-java/src/main/java/ly/count/sdk/java/internal/ImmediateRequestGenerator.java @@ -0,0 +1,5 @@ +package ly.count.sdk.java.internal; + +public interface ImmediateRequestGenerator { + ImmediateRequestI createImmediateRequestMaker(); +} diff --git a/sdk-java/src/main/java/ly/count/sdk/java/internal/ImmediateRequestI.java b/sdk-java/src/main/java/ly/count/sdk/java/internal/ImmediateRequestI.java index f1157edce..c91bc3c24 100644 --- a/sdk-java/src/main/java/ly/count/sdk/java/internal/ImmediateRequestI.java +++ b/sdk-java/src/main/java/ly/count/sdk/java/internal/ImmediateRequestI.java @@ -1,5 +1,5 @@ package ly.count.sdk.java.internal; -interface ImmediateRequestI { +public interface ImmediateRequestI { void doWork(String requestData, String customEndpoint, Transport cp, boolean requestShouldBeDelayed, boolean networkingIsEnabled, ImmediateRequestMaker.InternalImmediateRequestCallback callback, Log log); } diff --git a/sdk-java/src/main/java/ly/count/sdk/java/internal/InternalConfig.java b/sdk-java/src/main/java/ly/count/sdk/java/internal/InternalConfig.java index 2adfa0745..c65efe240 100644 --- a/sdk-java/src/main/java/ly/count/sdk/java/internal/InternalConfig.java +++ b/sdk-java/src/main/java/ly/count/sdk/java/internal/InternalConfig.java @@ -13,7 +13,6 @@ import java.util.List; import java.util.Map; import java.util.Set; - import ly.count.sdk.java.Config; /** @@ -34,6 +33,8 @@ public final class InternalConfig extends Config implements Storable { */ private final List dids = new ArrayList<>(); + ImmediateRequestGenerator immediateRequestGenerator = null; + /** * Shouldn't be used! */ diff --git a/sdk-java/src/main/java/ly/count/sdk/java/internal/SDKCore.java b/sdk-java/src/main/java/ly/count/sdk/java/internal/SDKCore.java index e5324b7cb..fb5b6be98 100644 --- a/sdk-java/src/main/java/ly/count/sdk/java/internal/SDKCore.java +++ b/sdk-java/src/main/java/ly/count/sdk/java/internal/SDKCore.java @@ -1,10 +1,14 @@ package ly.count.sdk.java.internal; -import ly.count.sdk.java.Config; -import org.json.JSONObject; - -import java.util.*; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Queue; +import java.util.TreeMap; import java.util.concurrent.Future; +import ly.count.sdk.java.Config; public class SDKCore { @@ -89,6 +93,10 @@ public boolean isTracking(Integer feat) { } public void init(CtxCore ctx) { + InternalConfig config = ctx.getConfig(); + if (config.immediateRequestGenerator == null) { + config.immediateRequestGenerator = ImmediateRequestMaker::new; + } prepareMappings(ctx); }