4
4
import com .launchdarkly .sdk .EvaluationReason .BigSegmentsStatus ;
5
5
import com .launchdarkly .sdk .server .integrations .ApplicationInfoBuilder ;
6
6
import com .launchdarkly .sdk .server .integrations .ServiceEndpointsBuilder ;
7
+ import com .launchdarkly .sdk .server .integrations .WrapperInfoBuilder ;
7
8
import com .launchdarkly .sdk .server .interfaces .ApplicationInfo ;
8
9
import com .launchdarkly .sdk .server .interfaces .BigSegmentsConfiguration ;
9
10
import com .launchdarkly .sdk .server .interfaces .ServiceEndpoints ;
11
+ import com .launchdarkly .sdk .server .interfaces .WrapperInfo ;
10
12
import com .launchdarkly .sdk .server .subsystems .ComponentConfigurer ;
11
13
import com .launchdarkly .sdk .server .subsystems .DataSource ;
12
14
import com .launchdarkly .sdk .server .subsystems .DataStore ;
@@ -24,7 +26,7 @@ public final class LDConfig {
24
26
* The default value for {@link Builder#startWait(Duration)}: 5 seconds.
25
27
*/
26
28
public static final Duration DEFAULT_START_WAIT = Duration .ofSeconds (5 );
27
-
29
+
28
30
protected static final LDConfig DEFAULT = new Builder ().build ();
29
31
30
32
final ApplicationInfo applicationInfo ;
@@ -39,6 +41,7 @@ public final class LDConfig {
39
41
final boolean offline ;
40
42
final Duration startWait ;
41
43
final int threadPriority ;
44
+ final WrapperInfo wrapperInfo ;
42
45
43
46
protected LDConfig (Builder builder ) {
44
47
if (builder .offline ) {
@@ -62,8 +65,9 @@ protected LDConfig(Builder builder) {
62
65
.createServiceEndpoints ();
63
66
this .startWait = builder .startWait ;
64
67
this .threadPriority = builder .threadPriority ;
68
+ this .wrapperInfo = builder .wrapperBuilder != null ? builder .wrapperBuilder .build () : null ;
65
69
}
66
-
70
+
67
71
/**
68
72
* A <a href="http://en.wikipedia.org/wiki/Builder_pattern">builder</a> that helps construct
69
73
* {@link com.launchdarkly.sdk.server.LDConfig} objects. Builder calls can be chained, enabling the
@@ -88,13 +92,35 @@ public static class Builder {
88
92
private boolean offline = false ;
89
93
private Duration startWait = DEFAULT_START_WAIT ;
90
94
private int threadPriority = Thread .MIN_PRIORITY ;
95
+ private WrapperInfoBuilder wrapperBuilder = null ;
91
96
92
97
/**
93
98
* Creates a builder with all configuration parameters set to the default
94
99
*/
95
100
public Builder () {
96
101
}
97
102
103
+ public static Builder fromConfig (LDConfig config ) {
104
+ Builder newBuilder = new Builder ();
105
+ newBuilder .applicationInfoBuilder = ApplicationInfoBuilder .fromApplicationInfo (config .applicationInfo );
106
+ newBuilder .bigSegments = config .bigSegments ;
107
+ newBuilder .dataSource = config .dataSource ;
108
+ newBuilder .dataStore = config .dataStore ;
109
+ newBuilder .diagnosticOptOut = config .diagnosticOptOut ;
110
+ newBuilder .events = config .events ;
111
+ newBuilder .http = config .http ;
112
+ newBuilder .logging = config .logging ;
113
+
114
+ newBuilder .serviceEndpointsBuilder = ComponentsImpl .ServiceEndpointsBuilderImpl
115
+ .fromServiceEndpoints (config .serviceEndpoints );
116
+ newBuilder .offline = config .offline ;
117
+ newBuilder .startWait = config .startWait ;
118
+ newBuilder .threadPriority = config .threadPriority ;
119
+ newBuilder .wrapperBuilder = config .wrapperInfo != null ?
120
+ ComponentsImpl .WrapperInfoBuilderImpl .fromInfo (config .wrapperInfo ) : null ;
121
+ return newBuilder ;
122
+ }
123
+
98
124
/**
99
125
* Sets the SDK's application metadata, which may be used in LaunchDarkly analytics or other product features,
100
126
* but does not affect feature flag evaluations.
@@ -144,7 +170,7 @@ public Builder bigSegments(ComponentConfigurer<BigSegmentsConfiguration> bigSegm
144
170
this .bigSegments = bigSegmentsConfigurer ;
145
171
return this ;
146
172
}
147
-
173
+
148
174
/**
149
175
* Sets the implementation of the component that receives feature flag data from LaunchDarkly,
150
176
* using a factory object. Depending on the implementation, the factory may be a builder that
@@ -154,7 +180,7 @@ public Builder bigSegments(ComponentConfigurer<BigSegmentsConfiguration> bigSegm
154
180
* {@link Components#pollingDataSource()}, or a test fixture such as
155
181
* {@link com.launchdarkly.sdk.server.integrations.FileData#dataSource()}. See those methods
156
182
* for details on how to configure them.
157
- *
183
+ *
158
184
* @param dataSourceConfigurer the data source configuration builder
159
185
* @return the main configuration builder
160
186
* @since 4.12.0
@@ -169,7 +195,7 @@ public Builder dataSource(ComponentConfigurer<DataSource> dataSourceConfigurer)
169
195
* related data received from LaunchDarkly, using a factory object. The default is
170
196
* {@link Components#inMemoryDataStore()}; for database integrations, use
171
197
* {@link Components#persistentDataStore(ComponentConfigurer)}.
172
- *
198
+ *
173
199
* @param dataStoreConfigurer the data store configuration builder
174
200
* @return the main configuration builder
175
201
* @since 4.12.0
@@ -206,7 +232,7 @@ public Builder diagnosticOptOut(boolean diagnosticOptOut) {
206
232
* {@link Components#sendEvents()} and then set custom options for event processing; or, disable
207
233
* events with {@link Components#noEvents()}; or, choose to use a custom implementation (for
208
234
* instance, a test fixture).
209
- *
235
+ *
210
236
* @param eventsConfigurer the events configuration builder
211
237
* @return the main configuration builder
212
238
* @since 4.12.0
@@ -222,7 +248,7 @@ public Builder events(ComponentConfigurer<EventProcessor> eventsConfigurer) {
222
248
* Sets the SDK's networking configuration, using a configuration builder. This builder is
223
249
* obtained from {@link Components#httpConfiguration()}, and has methods for setting individual
224
250
* HTTP-related properties.
225
- *
251
+ *
226
252
* @param httpConfigurer the HTTP configuration builder
227
253
* @return the main configuration builder
228
254
* @since 4.13.0
@@ -237,7 +263,7 @@ public Builder http(ComponentConfigurer<HttpConfiguration> httpConfigurer) {
237
263
* Sets the SDK's logging configuration, using a factory object. This object is normally a
238
264
* configuration builder obtained from {@link Components#logging()}, which has methods
239
265
* for setting individual logging-related properties.
240
- *
266
+ *
241
267
* @param loggingConfigurer the logging configuration builder
242
268
* @return the main configuration builder
243
269
* @since 5.0.0
@@ -258,7 +284,7 @@ public Builder logging(ComponentConfigurer<LoggingConfiguration> loggingConfigur
258
284
* This is equivalent to calling {@code dataSource(Components.externalUpdatesOnly())} and
259
285
* {@code events(Components.noEvents())}. It overrides any other values you may have set for
260
286
* {@link #dataSource(ComponentConfigurer)} or {@link #events(ComponentConfigurer)}.
261
- *
287
+ *
262
288
* @param offline when set to true no calls to LaunchDarkly will be made
263
289
* @return the builder
264
290
*/
@@ -267,7 +293,7 @@ public Builder offline(boolean offline) {
267
293
return this ;
268
294
}
269
295
270
- /**
296
+ /**
271
297
* Sets the base service URIs used by SDK components.
272
298
* <p>
273
299
* This object is normally a configuration builder obtained from {@link Components#serviceEndpoints()},
@@ -305,7 +331,7 @@ public Builder startWait(Duration startWait) {
305
331
* <p>
306
332
* Values outside the range of [{@code Thread.MIN_PRIORITY}, {@code Thread.MAX_PRIORITY}] will be set
307
333
* to the minimum or maximum.
308
- *
334
+ *
309
335
* @param threadPriority the priority for SDK threads
310
336
* @return the builder
311
337
* @since 5.0.0
@@ -314,7 +340,24 @@ public Builder threadPriority(int threadPriority) {
314
340
this .threadPriority = Math .max (Thread .MIN_PRIORITY , Math .min (Thread .MAX_PRIORITY , threadPriority ));
315
341
return this ;
316
342
}
317
-
343
+
344
+ /**
345
+ * Set the wrapper information.
346
+ * <p>
347
+ * This is intended for use with wrapper SDKs from LaunchDarkly.
348
+ * <p>
349
+ * If the WrapperBuilder is set, then it will replace the wrapper information from the HttpPropertiesBuilder.
350
+ * Additionally, any wrapper SDK may overwrite any application developer provided wrapper information.
351
+ *
352
+ * @param wrapperBuilder the wrapper builder
353
+ * @return the builder
354
+ * @since 7.1.0
355
+ */
356
+ public Builder wrapper (WrapperInfoBuilder wrapperBuilder ) {
357
+ this .wrapperBuilder = wrapperBuilder ;
358
+ return this ;
359
+ }
360
+
318
361
/**
319
362
* Builds the configured {@link com.launchdarkly.sdk.server.LDConfig} object.
320
363
*
0 commit comments