1616 */
1717package org .neo4j .driver .internal .adaptedbolt ;
1818
19- import java .time .Duration ;
20- import java .util .Map ;
19+ import java .util .List ;
2120import java .util .Objects ;
22- import java .util .Set ;
2321import java .util .concurrent .CompletionStage ;
24- import java .util .function .Supplier ;
25- import org .neo4j .bolt .connection .AccessMode ;
2622import org .neo4j .bolt .connection .AuthInfo ;
27- import org .neo4j .bolt .connection .AuthTokens ;
2823import org .neo4j .bolt .connection .BoltConnection ;
29- import org .neo4j .bolt .connection .BoltConnectionState ;
3024import org .neo4j .bolt .connection .BoltProtocolVersion ;
3125import org .neo4j .bolt .connection .BoltServerAddress ;
32- import org .neo4j .bolt .connection .DatabaseName ;
33- import org .neo4j .bolt .connection .NotificationConfig ;
34- import org .neo4j .bolt .connection .TelemetryApi ;
35- import org .neo4j .bolt .connection .TransactionType ;
36- import org .neo4j .driver .Value ;
26+ import org .neo4j .bolt .connection .message .Message ;
3727import org .neo4j .driver .internal .value .BoltValueFactory ;
3828
3929final class AdaptingDriverBoltConnection implements DriverBoltConnection {
@@ -49,141 +39,15 @@ final class AdaptingDriverBoltConnection implements DriverBoltConnection {
4939 }
5040
5141 @ Override
52- public <T > CompletionStage <T > onLoop (Supplier <T > supplier ) {
53- return connection .onLoop (supplier );
54- }
55-
56- @ Override
57- public CompletionStage <DriverBoltConnection > route (
58- DatabaseName databaseName , String impersonatedUser , Set <String > bookmarks ) {
59- return connection
60- .route (databaseName , impersonatedUser , bookmarks )
61- .exceptionally (errorMapper ::mapAndTrow )
62- .thenApply (ignored -> this );
63- }
64-
65- @ Override
66- public CompletionStage <DriverBoltConnection > beginTransaction (
67- DatabaseName databaseName ,
68- AccessMode accessMode ,
69- String impersonatedUser ,
70- Set <String > bookmarks ,
71- TransactionType transactionType ,
72- Duration txTimeout ,
73- Map <String , Value > txMetadata ,
74- String txType ,
75- NotificationConfig notificationConfig ) {
76- return connection
77- .beginTransaction (
78- databaseName ,
79- accessMode ,
80- impersonatedUser ,
81- bookmarks ,
82- transactionType ,
83- txTimeout ,
84- boltValueFactory .toBoltMap (txMetadata ),
85- txType ,
86- notificationConfig )
87- .exceptionally (errorMapper ::mapAndTrow )
88- .thenApply (ignored -> this );
89- }
90-
91- @ Override
92- public CompletionStage <DriverBoltConnection > runInAutoCommitTransaction (
93- DatabaseName databaseName ,
94- AccessMode accessMode ,
95- String impersonatedUser ,
96- Set <String > bookmarks ,
97- String query ,
98- Map <String , Value > parameters ,
99- Duration txTimeout ,
100- Map <String , Value > txMetadata ,
101- NotificationConfig notificationConfig ) {
102- return connection
103- .runInAutoCommitTransaction (
104- databaseName ,
105- accessMode ,
106- impersonatedUser ,
107- bookmarks ,
108- query ,
109- boltValueFactory .toBoltMap (parameters ),
110- txTimeout ,
111- boltValueFactory .toBoltMap (txMetadata ),
112- notificationConfig )
113- .exceptionally (errorMapper ::mapAndTrow )
114- .thenApply (ignored -> this );
115- }
116-
117- @ Override
118- public CompletionStage <DriverBoltConnection > run (String query , Map <String , Value > parameters ) {
119- return connection
120- .run (query , boltValueFactory .toBoltMap (parameters ))
121- .exceptionally (errorMapper ::mapAndTrow )
122- .thenApply (ignored -> this );
123- }
124-
125- @ Override
126- public CompletionStage <DriverBoltConnection > pull (long qid , long request ) {
127- return connection
128- .pull (qid , request )
129- .exceptionally (errorMapper ::mapAndTrow )
130- .thenApply (ignored -> this );
131- }
132-
133- @ Override
134- public CompletionStage <DriverBoltConnection > discard (long qid , long number ) {
42+ public CompletionStage <Void > writeAndFlush (DriverResponseHandler handler , List <Message > messages ) {
13543 return connection
136- .discard (qid , number )
137- .exceptionally (errorMapper ::mapAndTrow )
138- .thenApply (ignored -> this );
139- }
140-
141- @ Override
142- public CompletionStage <DriverBoltConnection > commit () {
143- return connection .commit ().exceptionally (errorMapper ::mapAndTrow ).thenApply (ignored -> this );
144- }
145-
146- @ Override
147- public CompletionStage <DriverBoltConnection > rollback () {
148- return connection .rollback ().exceptionally (errorMapper ::mapAndTrow ).thenApply (ignored -> this );
149- }
150-
151- @ Override
152- public CompletionStage <DriverBoltConnection > reset () {
153- return connection .reset ().exceptionally (errorMapper ::mapAndTrow ).thenApply (ignored -> this );
154- }
155-
156- @ Override
157- public CompletionStage <DriverBoltConnection > logoff () {
158- return connection .logoff ().exceptionally (errorMapper ::mapAndTrow ).thenApply (ignored -> this );
159- }
160-
161- @ Override
162- public CompletionStage <DriverBoltConnection > logon (Map <String , Value > authMap ) {
163- return connection
164- .logon (AuthTokens .custom (boltValueFactory .toBoltMap (authMap )))
165- .exceptionally (errorMapper ::mapAndTrow )
166- .thenApply (ignored -> this );
167- }
168-
169- @ Override
170- public CompletionStage <DriverBoltConnection > telemetry (TelemetryApi telemetryApi ) {
171- return connection
172- .telemetry (telemetryApi )
173- .exceptionally (errorMapper ::mapAndTrow )
174- .thenApply (ignored -> this );
175- }
176-
177- @ Override
178- public CompletionStage <DriverBoltConnection > clear () {
179- return connection .clear ().exceptionally (errorMapper ::mapAndTrow ).thenApply (ignored -> this );
44+ .writeAndFlush (new AdaptingDriverResponseHandler (handler , errorMapper , boltValueFactory ), messages )
45+ .exceptionally (errorMapper ::mapAndTrow );
18046 }
18147
18248 @ Override
183- public CompletionStage <Void > flush (DriverResponseHandler handler ) {
184- return connection
185- .flush (new AdaptingDriverResponseHandler (handler , errorMapper , boltValueFactory ))
186- .exceptionally (errorMapper ::mapAndTrow );
49+ public CompletionStage <Void > write (List <Message > messages ) {
50+ return connection .write (messages ).exceptionally (errorMapper ::mapAndTrow );
18751 }
18852
18953 @ Override
@@ -196,11 +60,6 @@ public CompletionStage<Void> close() {
19660 return connection .close ().exceptionally (errorMapper ::mapAndTrow );
19761 }
19862
199- @ Override
200- public BoltConnectionState state () {
201- return connection .state ();
202- }
203-
20463 @ Override
20564 public CompletionStage <AuthInfo > authData () {
20665 return connection .authInfo ().exceptionally (errorMapper ::mapAndTrow );
@@ -230,4 +89,9 @@ public boolean telemetrySupported() {
23089 public boolean serverSideRoutingEnabled () {
23190 return connection .serverSideRoutingEnabled ();
23291 }
92+
93+ @ Override
94+ public BoltValueFactory valueFactory () {
95+ return boltValueFactory ;
96+ }
23397}
0 commit comments