|
23 | 23 | import com.optimizely.ab.event.EventHandler;
|
24 | 24 | import com.optimizely.ab.internal.PropertyUtils;
|
25 | 25 | import com.optimizely.ab.notification.NotificationCenter;
|
| 26 | +import org.apache.http.impl.client.CloseableHttpClient; |
26 | 27 | import org.slf4j.Logger;
|
27 | 28 | import org.slf4j.LoggerFactory;
|
28 | 29 |
|
@@ -247,11 +248,26 @@ public static Optimizely newDefaultInstance(String sdkKey, String fallback) {
|
247 | 248 | * @return A new Optimizely instance
|
248 | 249 | */
|
249 | 250 | public static Optimizely newDefaultInstance(String sdkKey, String fallback, String datafileAccessToken) {
|
| 251 | + return newDefaultInstance(sdkKey, fallback, datafileAccessToken, null); |
| 252 | + } |
| 253 | + |
| 254 | + /** |
| 255 | + * Returns a new Optimizely instance with authenticated datafile support. |
| 256 | + * |
| 257 | + * @param sdkKey SDK key used to build the ProjectConfigManager. |
| 258 | + * @param fallback Fallback datafile string used by the ProjectConfigManager to be immediately available. |
| 259 | + * @param datafileAccessToken Token for authenticated datafile access. |
| 260 | + * @param customHttpClient Customizable CloseableHttpClient to build OptimizelyHttpClient. |
| 261 | + * @return A new Optimizely instance |
| 262 | + */ |
| 263 | + public static Optimizely newDefaultInstance(String sdkKey, String fallback, String datafileAccessToken, CloseableHttpClient customHttpClient) { |
250 | 264 | NotificationCenter notificationCenter = new NotificationCenter();
|
251 |
| - |
252 |
| - HttpProjectConfigManager.Builder builder = HttpProjectConfigManager.builder() |
| 265 | + OptimizelyHttpClient optimizelyHttpClient = new OptimizelyHttpClient(customHttpClient); |
| 266 | + HttpProjectConfigManager.Builder builder; |
| 267 | + builder = HttpProjectConfigManager.builder() |
253 | 268 | .withDatafile(fallback)
|
254 | 269 | .withNotificationCenter(notificationCenter)
|
| 270 | + .withOptimizelyHttpClient(customHttpClient == null ? null : optimizelyHttpClient) |
255 | 271 | .withSdkKey(sdkKey);
|
256 | 272 |
|
257 | 273 | if (datafileAccessToken != null) {
|
|
0 commit comments