@@ -119,13 +119,16 @@ public final class MssqlConnectionConfiguration {
119
119
120
120
private final String username ;
121
121
122
+ @ Nullable
123
+ private final ConnectionProvider connectionProvider ;
124
+
122
125
private MssqlConnectionConfiguration (@ Nullable String applicationName , @ Nullable UUID connectionId , Duration connectTimeout , @ Nullable String database , String host , String hostNameInCertificate ,
123
126
@ Nullable Duration lockWaitTimeout , CharSequence password , Predicate <String > preferCursoredExecution , int port , boolean sendStringParametersAsUnicode ,
124
127
boolean ssl ,
125
128
Function <SslContextBuilder , SslContextBuilder > sslContextBuilderCustomizer ,
126
129
@ Nullable Function <SslContextBuilder , SslContextBuilder > sslTunnelSslContextBuilderCustomizer , boolean tcpKeepAlive , boolean tcpNoDelay ,
127
130
boolean trustServerCertificate , @ Nullable File trustStore , @ Nullable String trustStoreType ,
128
- @ Nullable char [] trustStorePassword , String username ) {
131
+ @ Nullable char [] trustStorePassword , String username , @ Nullable ConnectionProvider connectionProvider ) {
129
132
130
133
this .applicationName = applicationName ;
131
134
this .connectionId = connectionId ;
@@ -148,6 +151,7 @@ private MssqlConnectionConfiguration(@Nullable String applicationName, @Nullable
148
151
this .trustStoreType = trustStoreType ;
149
152
this .trustStorePassword = trustStorePassword ;
150
153
this .username = Assert .requireNonNull (username , "username must not be null" );
154
+ this .connectionProvider = connectionProvider ;
151
155
}
152
156
153
157
/**
@@ -185,12 +189,14 @@ MssqlConnectionConfiguration withRedirect(Redirect redirect) {
185
189
return new MssqlConnectionConfiguration (this .applicationName , this .connectionId , this .connectTimeout , this .database , redirectServerName , hostNameInCertificate , this .lockWaitTimeout ,
186
190
this .password ,
187
191
this .preferCursoredExecution , redirect .getPort (), this .sendStringParametersAsUnicode , this .ssl , this .sslContextBuilderCustomizer ,
188
- this .sslTunnelSslContextBuilderCustomizer , this .tcpKeepAlive , this .tcpNoDelay , this .trustServerCertificate , this .trustStore , this .trustStoreType , this .trustStorePassword , this .username );
192
+ this .sslTunnelSslContextBuilderCustomizer , this .tcpKeepAlive , this .tcpNoDelay , this .trustServerCertificate , this .trustStore , this .trustStoreType , this .trustStorePassword , this .username ,
193
+ this .connectionProvider );
189
194
}
190
195
191
196
ClientConfiguration toClientConfiguration () {
192
197
return new DefaultClientConfiguration (this .connectTimeout , this .host , this .hostNameInCertificate , this .port , this .ssl , this .sslContextBuilderCustomizer ,
193
- this .sslTunnelSslContextBuilderCustomizer , this .tcpKeepAlive , this .tcpNoDelay , this .trustServerCertificate , this .trustStore , this .trustStoreType , this .trustStorePassword );
198
+ this .sslTunnelSslContextBuilderCustomizer , this .tcpKeepAlive , this .tcpNoDelay , this .trustServerCertificate , this .trustStore , this .trustStoreType , this .trustStorePassword ,
199
+ this .connectionProvider );
194
200
}
195
201
196
202
ConnectionOptions toConnectionOptions () {
@@ -387,6 +393,9 @@ public static final class Builder {
387
393
@ Nullable
388
394
private char [] trustStorePassword ;
389
395
396
+ @ Nullable
397
+ private ConnectionProvider connectionProvider ;
398
+
390
399
private Builder () {
391
400
}
392
401
@@ -703,6 +712,18 @@ public Builder username(String username) {
703
712
return this ;
704
713
}
705
714
715
+ /**
716
+ * Configure the {@link ConnectionProvider} to be used with Netty
717
+ *
718
+ * @param connectionProvider the connection provider
719
+ * @return this {@link Builder}
720
+ * @since 1.1.0
721
+ */
722
+ public Builder connectionProvider (ConnectionProvider connectionProvider ) {
723
+ this .connectionProvider = connectionProvider ;
724
+ return this ;
725
+ }
726
+
706
727
/**
707
728
* Returns a configured {@link MssqlConnectionConfiguration}.
708
729
*
@@ -719,7 +740,7 @@ public MssqlConnectionConfiguration build() {
719
740
this .preferCursoredExecution , this .port , this .sendStringParametersAsUnicode , this .ssl , this .sslContextBuilderCustomizer ,
720
741
this .sslTunnelSslContextBuilderCustomizer , this .tcpKeepAlive ,
721
742
this .tcpNoDelay , this .trustServerCertificate , this .trustStore ,
722
- this .trustStoreType , this .trustStorePassword , this .username );
743
+ this .trustStoreType , this .trustStorePassword , this .username , this . connectionProvider );
723
744
}
724
745
725
746
}
@@ -756,10 +777,14 @@ static class DefaultClientConfiguration implements ClientConfiguration {
756
777
@ Nullable
757
778
private final char [] trustStorePassword ;
758
779
780
+ @ Nullable
781
+ private final ConnectionProvider connectionProvider ;
782
+
759
783
DefaultClientConfiguration (Duration connectTimeout , String host , String hostNameInCertificate , int port , boolean ssl ,
760
784
Function <SslContextBuilder , SslContextBuilder > sslContextBuilderCustomizer ,
761
785
@ Nullable Function <SslContextBuilder , SslContextBuilder > sslTunnelSslContextBuilderCustomizer , boolean tcpKeepAlive , boolean tcpNoDelay ,
762
- boolean trustServerCertificate , @ Nullable File trustStore , @ Nullable String trustStoreType , @ Nullable char [] trustStorePassword ) {
786
+ boolean trustServerCertificate , @ Nullable File trustStore , @ Nullable String trustStoreType , @ Nullable char [] trustStorePassword ,
787
+ ConnectionProvider connectionProvider ) {
763
788
764
789
this .connectTimeout = connectTimeout ;
765
790
this .host = host ;
@@ -774,6 +799,7 @@ static class DefaultClientConfiguration implements ClientConfiguration {
774
799
this .trustStore = trustStore ;
775
800
this .trustStoreType = trustStoreType ;
776
801
this .trustStorePassword = trustStorePassword ;
802
+ this .connectionProvider = connectionProvider ;
777
803
}
778
804
779
805
@ Override
@@ -803,7 +829,8 @@ public boolean isTcpNoDelay() {
803
829
804
830
@ Override
805
831
public ConnectionProvider getConnectionProvider () {
806
- return ConnectionProvider .newConnection ();
832
+ return Optional .ofNullable (connectionProvider )
833
+ .orElseGet (ConnectionProvider ::newConnection );
807
834
}
808
835
809
836
@ Override
0 commit comments