@@ -75,7 +75,11 @@ public final class Config implements Serializable {
75
75
76
76
private static final Config EMPTY = builder ().build ();
77
77
78
- /** User defined logging */
78
+ private final BookmarkManager queryBookmarkManager ;
79
+
80
+ /**
81
+ * User defined logging
82
+ */
79
83
private final Logging logging ;
80
84
81
85
private final boolean logLeakedSessions ;
@@ -100,6 +104,7 @@ public final class Config implements Serializable {
100
104
private final MetricsAdapter metricsAdapter ;
101
105
102
106
private Config (ConfigBuilder builder ) {
107
+ this .queryBookmarkManager = builder .queryBookmarkManager ;
103
108
this .logging = builder .logging ;
104
109
this .logLeakedSessions = builder .logLeakedSessions ;
105
110
@@ -121,8 +126,22 @@ private Config(ConfigBuilder builder) {
121
126
this .metricsAdapter = builder .metricsAdapter ;
122
127
}
123
128
129
+ /**
130
+ * A {@link BookmarkManager} implementation for the driver to use on
131
+ * {@link Driver#executeQuery(Query, QueryConfig)} method and its variants by default.
132
+ * <p>
133
+ * Please note that sessions will not use this automatically, but it is possible to enable it explicitly
134
+ * using {@link SessionConfig.Builder#withBookmarkManager(BookmarkManager)}.
135
+ *
136
+ * @return bookmark manager, must not be {@code null}
137
+ */
138
+ public BookmarkManager queryBookmarkManager () {
139
+ return queryBookmarkManager ;
140
+ }
141
+
124
142
/**
125
143
* Logging provider
144
+ *
126
145
* @return the Logging provider to use
127
146
*/
128
147
public Logging logging () {
@@ -256,6 +275,8 @@ public String userAgent() {
256
275
* Used to build new config instances
257
276
*/
258
277
public static final class ConfigBuilder {
278
+ private BookmarkManager queryBookmarkManager =
279
+ BookmarkManagers .defaultManager (BookmarkManagerConfig .builder ().build ());
259
280
private Logging logging = DEV_NULL_LOGGING ;
260
281
private boolean logLeakedSessions ;
261
282
private int maxConnectionPoolSize = PoolSettings .DEFAULT_MAX_CONNECTION_POOL_SIZE ;
@@ -275,6 +296,22 @@ public static final class ConfigBuilder {
275
296
276
297
private ConfigBuilder () {}
277
298
299
+ /**
300
+ * Sets a {@link BookmarkManager} implementation for the driver to use on
301
+ * {@link Driver#executeQuery(Query, QueryConfig)} method and its variants by default.
302
+ * <p>
303
+ * Please note that sessions will not use this automatically, but it is possible to enable it explicitly
304
+ * using {@link SessionConfig.Builder#withBookmarkManager(BookmarkManager)}.
305
+ *
306
+ * @param queryBookmarkManager bookmark manager, must not be {@code null}
307
+ * @return this builder
308
+ */
309
+ public ConfigBuilder withQueryBookmarkManager (BookmarkManager queryBookmarkManager ) {
310
+ Objects .requireNonNull (queryBookmarkManager , "queryBookmarkManager must not be null" );
311
+ this .queryBookmarkManager = queryBookmarkManager ;
312
+ return this ;
313
+ }
314
+
278
315
/**
279
316
* Provide a logging implementation for the driver to use. Java logging framework {@link java.util.logging} with {@link Level#INFO} is used by default.
280
317
* Callers are expected to either implement {@link Logging} interface or provide one of the existing implementations available from static factory
@@ -331,7 +368,7 @@ public ConfigBuilder withLeakedSessionsLogging() {
331
368
* validity and negative values mean connections will never be tested.
332
369
*
333
370
* @param value the minimum idle time
334
- * @param unit the unit in which the duration is given
371
+ * @param unit the unit in which the duration is given
335
372
* @return this builder
336
373
*/
337
374
public ConfigBuilder withConnectionLivenessCheckTimeout (long value , TimeUnit unit ) {
@@ -356,7 +393,7 @@ public ConfigBuilder withConnectionLivenessCheckTimeout(long value, TimeUnit uni
356
393
* checked.
357
394
*
358
395
* @param value the maximum connection lifetime
359
- * @param unit the unit in which the duration is given
396
+ * @param unit the unit in which the duration is given
360
397
* @return this builder
361
398
*/
362
399
public ConfigBuilder withMaxConnectionLifetime (long value , TimeUnit unit ) {
@@ -402,7 +439,7 @@ public ConfigBuilder withMaxConnectionPoolSize(int value) {
402
439
* of {@code 0} is allowed and results in no timeout and immediate failure when connection is unavailable.
403
440
*
404
441
* @param value the acquisition timeout
405
- * @param unit the unit in which the duration is given
442
+ * @param unit the unit in which the duration is given
406
443
* @return this builder
407
444
* @see #withMaxConnectionPoolSize(int)
408
445
*/
@@ -418,6 +455,7 @@ public ConfigBuilder withConnectionAcquisitionTimeout(long value, TimeUnit unit)
418
455
419
456
/**
420
457
* Set to use encrypted traffic.
458
+ *
421
459
* @return this builder
422
460
*/
423
461
public ConfigBuilder withEncryption () {
@@ -427,6 +465,7 @@ public ConfigBuilder withEncryption() {
427
465
428
466
/**
429
467
* Set to use unencrypted traffic.
468
+ *
430
469
* @return this builder
431
470
*/
432
471
public ConfigBuilder withoutEncryption () {
@@ -461,13 +500,12 @@ public ConfigBuilder withTrustStrategy(TrustStrategy trustStrategy) {
461
500
* The routing table of a database get refreshed if the database is used frequently.
462
501
* If the database is not used for a long time,
463
502
* the driver use the timeout specified here to purge the stale routing table.
464
- *
503
+ * <p>
465
504
* After a routing table is removed, next time when using the database of the purged routing table,
466
505
* the driver will fall back to use seed URI for a new routing table.
467
- * @param delay
468
- * the amount of time to wait before purging routing tables
469
- * @param unit
470
- * the unit in which the duration is given
506
+ *
507
+ * @param delay the amount of time to wait before purging routing tables
508
+ * @param unit the unit in which the duration is given
471
509
* @return this builder
472
510
*/
473
511
public ConfigBuilder withRoutingTablePurgeDelay (long delay , TimeUnit unit ) {
@@ -483,15 +521,16 @@ public ConfigBuilder withRoutingTablePurgeDelay(long delay, TimeUnit unit) {
483
521
/**
484
522
* Specify how many records to fetch in each batch.
485
523
* This config is only valid when the driver is used with servers that support Bolt V4 (Server version 4.0 and later).
486
- *
524
+ * <p>
487
525
* Bolt V4 enables pulling records in batches to allow client to take control of data population and apply back pressure to server.
488
526
* This config specifies the default fetch size for all query runs using {@link Session} and {@link org.neo4j.driver.async.AsyncSession}.
489
527
* By default, the value is set to {@code 1000}.
490
528
* Use {@code -1} to disables back pressure and config client to pull all records at once after each run.
491
- *
529
+ * <p>
492
530
* This config only applies to run result obtained via {@link Session} and {@link org.neo4j.driver.async.AsyncSession}.
493
531
* As with {@link org.neo4j.driver.reactive.RxSession}, the batch size is provided via
494
532
* {@link org.reactivestreams.Subscription#request(long)} instead.
533
+ *
495
534
* @param size the default record fetch size when pulling records in batches using Bolt V4.
496
535
* @return this builder
497
536
*/
@@ -512,10 +551,10 @@ public ConfigBuilder withFetchSize(long size) {
512
551
* The default value of this parameter is {@code 30 SECONDS}.
513
552
*
514
553
* @param value the timeout duration
515
- * @param unit the unit in which duration is given
554
+ * @param unit the unit in which duration is given
516
555
* @return this builder
517
556
* @throws IllegalArgumentException when given value is negative or does not fit in {@code int} when
518
- * converted to milliseconds.
557
+ * converted to milliseconds.
519
558
*/
520
559
public ConfigBuilder withConnectionTimeout (long value , TimeUnit unit ) {
521
560
long connectionTimeoutMillis = unit .toMillis (value );
@@ -543,7 +582,7 @@ public ConfigBuilder withConnectionTimeout(long value, TimeUnit unit) {
543
582
* Default value is 30 seconds.
544
583
*
545
584
* @param value the timeout duration
546
- * @param unit the unit in which duration is given
585
+ * @param unit the unit in which duration is given
547
586
* @return this builder
548
587
* @throws IllegalArgumentException when given value is negative
549
588
*/
@@ -586,6 +625,7 @@ public ConfigBuilder withDriverMetrics() {
586
625
587
626
/**
588
627
* Disable driver metrics. When disabled, driver metrics cannot be accessed via {@link Driver#metrics()}.
628
+ *
589
629
* @return this builder.
590
630
*/
591
631
public ConfigBuilder withoutDriverMetrics () {
@@ -619,6 +659,7 @@ public ConfigBuilder withMetricsAdapter(MetricsAdapter metricsAdapter) {
619
659
/**
620
660
* Configure the event loop thread count. This specifies how many threads the driver can use to handle network I/O events
621
661
* and user's events in driver's I/O threads. By default, 2 * NumberOfProcessors amount of threads will be used instead.
662
+ *
622
663
* @param size the thread count.
623
664
* @return this builder.
624
665
* @throws IllegalArgumentException if the value of the size is set to a number that is less than 1.
@@ -634,6 +675,7 @@ public ConfigBuilder withEventLoopThreads(int size) {
634
675
635
676
/**
636
677
* Configure the user_agent field sent to the server to identify the connected client.
678
+ *
637
679
* @param userAgent the string to configure user_agent.
638
680
* @return this builder.
639
681
*/
@@ -802,6 +844,7 @@ public static TrustStrategy trustAllCertificates() {
802
844
803
845
/**
804
846
* The revocation strategy used for verifying certificates.
847
+ *
805
848
* @return this {@link TrustStrategy}'s revocation strategy
806
849
*/
807
850
public RevocationCheckingStrategy revocationCheckingStrategy () {
@@ -811,6 +854,7 @@ public RevocationCheckingStrategy revocationCheckingStrategy() {
811
854
/**
812
855
* Configures the {@link TrustStrategy} to not carry out OCSP revocation checks on certificates. This is the
813
856
* option that is configured by default.
857
+ *
814
858
* @return the current trust strategy
815
859
*/
816
860
public TrustStrategy withoutCertificateRevocationChecks () {
@@ -823,6 +867,7 @@ public TrustStrategy withoutCertificateRevocationChecks() {
823
867
* stapled to the certificate. If no stapled response is found, then certificate verification continues
824
868
* (and does not fail verification). This setting also requires the server to be configured to enable
825
869
* OCSP stapling.
870
+ *
826
871
* @return the current trust strategy
827
872
*/
828
873
public TrustStrategy withVerifyIfPresentRevocationChecks () {
@@ -834,9 +879,10 @@ public TrustStrategy withVerifyIfPresentRevocationChecks() {
834
879
* Configures the {@link TrustStrategy} to carry out strict OCSP revocation checks for revocation status that
835
880
* are stapled to the certificate. If no stapled response is found, then the driver will fail certificate verification
836
881
* and not connect to the server. This setting also requires the server to be configured to enable OCSP stapling.
837
- *
882
+ * <p>
838
883
* Note: enabling this setting will prevent the driver connecting to the server when the server is unable to reach
839
884
* the certificate's configured OCSP responder URL.
885
+ *
840
886
* @return the current trust strategy
841
887
*/
842
888
public TrustStrategy withStrictRevocationChecks () {
0 commit comments