Skip to content

Commit 32de528

Browse files
committed
Review comments for driver service
1 parent f11fe45 commit 32de528

File tree

17 files changed

+143
-66
lines changed

17 files changed

+143
-66
lines changed

vertx-db2-client/src/main/java/io/vertx/db2client/DB2Driver.java renamed to vertx-db2-client/src/main/java/io/vertx/db2client/spi/DB2Driver.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,39 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.vertx.db2client;
16+
package io.vertx.db2client.spi;
1717

1818
import io.vertx.core.Vertx;
19-
import io.vertx.sqlclient.Driver;
19+
import io.vertx.db2client.DB2ConnectOptions;
20+
import io.vertx.db2client.DB2Pool;
2021
import io.vertx.sqlclient.Pool;
2122
import io.vertx.sqlclient.PoolOptions;
2223
import io.vertx.sqlclient.SqlConnectOptions;
24+
import io.vertx.sqlclient.spi.Driver;
2325

2426
public class DB2Driver implements Driver {
2527

2628
@Override
2729
public Pool createPool(SqlConnectOptions options, PoolOptions poolOptions) {
28-
return DB2Pool.pool(new DB2ConnectOptions(options), poolOptions);
30+
return DB2Pool.pool(wrap(options), poolOptions);
2931
}
3032

3133
@Override
3234
public Pool createPool(Vertx vertx, SqlConnectOptions options, PoolOptions poolOptions) {
33-
return DB2Pool.pool(vertx, new DB2ConnectOptions(options), poolOptions);
35+
return DB2Pool.pool(vertx, wrap(options), poolOptions);
3436
}
3537

3638
@Override
3739
public boolean acceptsOptions(SqlConnectOptions options) {
3840
return options instanceof DB2ConnectOptions || SqlConnectOptions.class.equals(options.getClass());
3941
}
42+
43+
private static DB2ConnectOptions wrap(SqlConnectOptions options) {
44+
if (options instanceof DB2ConnectOptions) {
45+
return (DB2ConnectOptions) options;
46+
} else {
47+
return new DB2ConnectOptions(options);
48+
}
49+
}
4050

4151
}

vertx-db2-client/src/main/resources/META-INF/services/io.vertx.sqlclient.Driver

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
io.vertx.db2client.spi.DB2Driver

vertx-mssql-client/src/main/java/io/vertx/mssqlclient/MSSQLDriver.java

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright (C) 2020 IBM Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.vertx.mssqlclient.spi;
17+
18+
import io.vertx.core.Vertx;
19+
import io.vertx.mssqlclient.MSSQLConnectOptions;
20+
import io.vertx.mssqlclient.MSSQLPool;
21+
import io.vertx.sqlclient.Pool;
22+
import io.vertx.sqlclient.PoolOptions;
23+
import io.vertx.sqlclient.SqlConnectOptions;
24+
import io.vertx.sqlclient.spi.Driver;
25+
26+
public class MSSQLDriver implements Driver {
27+
28+
@Override
29+
public Pool createPool(SqlConnectOptions options, PoolOptions poolOptions) {
30+
return MSSQLPool.pool(wrap(options), poolOptions);
31+
}
32+
33+
@Override
34+
public Pool createPool(Vertx vertx, SqlConnectOptions options, PoolOptions poolOptions) {
35+
return MSSQLPool.pool(vertx, wrap(options), poolOptions);
36+
}
37+
38+
@Override
39+
public boolean acceptsOptions(SqlConnectOptions options) {
40+
return options instanceof MSSQLConnectOptions || SqlConnectOptions.class.equals(options.getClass());
41+
}
42+
43+
private static MSSQLConnectOptions wrap(SqlConnectOptions options) {
44+
if (options instanceof MSSQLConnectOptions) {
45+
return (MSSQLConnectOptions) options;
46+
} else {
47+
return new MSSQLConnectOptions(options);
48+
}
49+
}
50+
51+
}

vertx-mssql-client/src/main/resources/META-INF/services/io.vertx.sqlclient.Driver

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
io.vertx.mssqlclient.spi.MSSQLDriver

vertx-mysql-client/src/main/java/io/vertx/mysqlclient/MySQLDriver.java

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright (C) 2020 IBM Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.vertx.mysqlclient.spi;
17+
18+
import io.vertx.core.Vertx;
19+
import io.vertx.mysqlclient.MySQLConnectOptions;
20+
import io.vertx.mysqlclient.MySQLPool;
21+
import io.vertx.sqlclient.Pool;
22+
import io.vertx.sqlclient.PoolOptions;
23+
import io.vertx.sqlclient.SqlConnectOptions;
24+
import io.vertx.sqlclient.spi.Driver;
25+
26+
public class MySQLDriver implements Driver {
27+
28+
@Override
29+
public Pool createPool(SqlConnectOptions options, PoolOptions poolOptions) {
30+
return MySQLPool.pool(wrap(options), poolOptions);
31+
}
32+
33+
@Override
34+
public Pool createPool(Vertx vertx, SqlConnectOptions options, PoolOptions poolOptions) {
35+
return MySQLPool.pool(vertx, wrap(options), poolOptions);
36+
}
37+
38+
@Override
39+
public boolean acceptsOptions(SqlConnectOptions options) {
40+
return options instanceof MySQLConnectOptions || SqlConnectOptions.class.equals(options.getClass());
41+
}
42+
43+
private static MySQLConnectOptions wrap(SqlConnectOptions options) {
44+
if (options instanceof MySQLConnectOptions) {
45+
return (MySQLConnectOptions) options;
46+
} else {
47+
return new MySQLConnectOptions(options);
48+
}
49+
}
50+
51+
}

vertx-mysql-client/src/main/resources/META-INF/services/io.vertx.sqlclient.Driver

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)