From 47ad6a8fcb3c49e7e07abb8a2915c3d895448c26 Mon Sep 17 00:00:00 2001 From: Michael-A-McMahon Date: Fri, 5 Mar 2021 13:47:43 -0800 Subject: [PATCH 1/4] Expanding ADB acronym --- sample/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample/README.md b/sample/README.md index 0375313..34651f4 100644 --- a/sample/README.md +++ b/sample/README.md @@ -1,5 +1,5 @@ # Oracle R2DBC code examples -A simple R2DBC program that connects to ADB and executes a query +A simple R2DBC program that connects to Autonomous Database and executes a query # Building manually From 5be5c71ad17392259493efb8b01d68eadc75b26e Mon Sep 17 00:00:00 2001 From: Michael-A-McMahon Date: Fri, 5 Mar 2021 21:43:07 -0800 Subject: [PATCH 2/4] Add module-info.java, and make tests module compatible. --- pom.xml | 2 +- src/main/java/module-info.java | 38 ++++++++ .../r2dbc/impl/OracleConnectionImpl.java | 2 - .../r2dbc/impl/OracleReactiveJdbcAdapter.java | 12 +-- .../oracle/r2dbc/impl/OracleResultImpl.java | 1 - .../java/oracle/r2dbc/impl/OracleRowImpl.java | 5 - .../r2dbc/impl/OracleStatementImpl.java | 4 +- .../r2dbc/impl/ReactiveJdbcAdapter.java | 1 - src/test/java/oracle/r2dbc/OracleTestKit.java | 69 ++++++++++---- .../r2dbc/impl/OracleResultImplTest.java | 8 +- .../r2dbc/impl/OracleStatementImplTest.java | 19 ++-- .../r2dbc/util/DatabaseConfigExtension.java | 92 ------------------- .../r2dbc/util/OracleTestKitSupport.java | 67 -------------- 13 files changed, 104 insertions(+), 216 deletions(-) create mode 100644 src/main/java/module-info.java delete mode 100755 src/test/java/oracle/r2dbc/util/DatabaseConfigExtension.java delete mode 100755 src/test/java/oracle/r2dbc/util/OracleTestKitSupport.java diff --git a/pom.xml b/pom.xml index c9bd1a0..aded4b9 100755 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,7 @@ maven-javadoc-plugin 3.2.0 -
Oracle R2DBC ${version}
+
Oracle R2DBC ${project.version}
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java new file mode 100644 index 0000000..af213c3 --- /dev/null +++ b/src/main/java/module-info.java @@ -0,0 +1,38 @@ +/* + Copyright (c) 2020, 2021, Oracle and/or its affiliates. + + This software is dual-licensed to you under the Universal Permissive License + (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License + 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose + either license. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +/** + * Implements the R2DBC SPI for Oracle Database. + * + * @provides io.r2dbc.spi.ConnectionFactoryProvider + * @since 0.1.1 + */ +module oracle.r2dbc { + + provides io.r2dbc.spi.ConnectionFactoryProvider + with oracle.r2dbc.impl.OracleConnectionFactoryProviderImpl; + + requires java.sql; + + requires ojdbc11; + requires org.reactivestreams; + requires reactor.core; + requires r2dbc.spi; +} diff --git a/src/main/java/oracle/r2dbc/impl/OracleConnectionImpl.java b/src/main/java/oracle/r2dbc/impl/OracleConnectionImpl.java index d535a18..d9dfd23 100755 --- a/src/main/java/oracle/r2dbc/impl/OracleConnectionImpl.java +++ b/src/main/java/oracle/r2dbc/impl/OracleConnectionImpl.java @@ -32,8 +32,6 @@ import reactor.core.publisher.Mono; import static java.sql.Connection.TRANSACTION_READ_COMMITTED; -import static java.sql.Connection.TRANSACTION_READ_UNCOMMITTED; -import static java.sql.Connection.TRANSACTION_REPEATABLE_READ; import static java.sql.Connection.TRANSACTION_SERIALIZABLE; import static oracle.r2dbc.impl.OracleR2dbcExceptions.requireNonNull; import static oracle.r2dbc.impl.OracleR2dbcExceptions.getOrHandleSQLException; diff --git a/src/main/java/oracle/r2dbc/impl/OracleReactiveJdbcAdapter.java b/src/main/java/oracle/r2dbc/impl/OracleReactiveJdbcAdapter.java index 52d8c96..db4b960 100755 --- a/src/main/java/oracle/r2dbc/impl/OracleReactiveJdbcAdapter.java +++ b/src/main/java/oracle/r2dbc/impl/OracleReactiveJdbcAdapter.java @@ -25,8 +25,6 @@ import io.r2dbc.spi.Option; import io.r2dbc.spi.R2dbcException; import io.r2dbc.spi.R2dbcTimeoutException; -import io.r2dbc.spi.Result; -import io.r2dbc.spi.Row; import oracle.jdbc.OracleBlob; import oracle.jdbc.OracleClob; import oracle.jdbc.OracleConnection; @@ -49,17 +47,12 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.sql.RowId; import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Types; import java.sql.Wrapper; import java.time.Duration; -import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Flow; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.locks.ReentrantLock; @@ -426,10 +419,11 @@ static OracleReactiveJdbcAdapter getInstance() { @Override public DataSource createDataSource(ConnectionFactoryOptions options) { - oracle.jdbc.pool.OracleDataSource oracleDataSource = + OracleDataSource oracleDataSource = getOrHandleSQLException(oracle.jdbc.pool.OracleDataSource::new); - oracleDataSource.setURL(composeJdbcUrl(options)); + runOrHandleSQLException(() -> + oracleDataSource.setURL(composeJdbcUrl(options))); configureStandardOptions(oracleDataSource, options); configureExtendedOptions(oracleDataSource, options); configureJdbcDefaults(oracleDataSource); diff --git a/src/main/java/oracle/r2dbc/impl/OracleResultImpl.java b/src/main/java/oracle/r2dbc/impl/OracleResultImpl.java index ed35b15..b6213ff 100755 --- a/src/main/java/oracle/r2dbc/impl/OracleResultImpl.java +++ b/src/main/java/oracle/r2dbc/impl/OracleResultImpl.java @@ -23,7 +23,6 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.sql.SQLException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.BiFunction; diff --git a/src/main/java/oracle/r2dbc/impl/OracleRowImpl.java b/src/main/java/oracle/r2dbc/impl/OracleRowImpl.java index 3041abe..7c36969 100755 --- a/src/main/java/oracle/r2dbc/impl/OracleRowImpl.java +++ b/src/main/java/oracle/r2dbc/impl/OracleRowImpl.java @@ -25,15 +25,10 @@ import io.r2dbc.spi.Clob; import io.r2dbc.spi.R2dbcException; import io.r2dbc.spi.Row; -import oracle.jdbc.OracleType; -import java.io.IOException; import java.nio.ByteBuffer; -import java.sql.JDBCType; import java.sql.ResultSet; -import java.sql.SQLType; import java.sql.Types; -import java.util.Objects; import static oracle.r2dbc.impl.OracleR2dbcExceptions.requireNonNull; diff --git a/src/main/java/oracle/r2dbc/impl/OracleStatementImpl.java b/src/main/java/oracle/r2dbc/impl/OracleStatementImpl.java index a54186a..0ba8a26 100755 --- a/src/main/java/oracle/r2dbc/impl/OracleStatementImpl.java +++ b/src/main/java/oracle/r2dbc/impl/OracleStatementImpl.java @@ -24,7 +24,6 @@ import io.r2dbc.spi.R2dbcException; import io.r2dbc.spi.Result; import io.r2dbc.spi.Statement; -import oracle.r2dbc.impl.OracleR2dbcExceptions.ThrowingRunnable; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -547,6 +546,7 @@ private Publisher createResultPublisher( * signal. *

* @param jdbcStatement A JDBC statement + * @param bindValues A set of bind values * @return A publisher that emits the {@code Result} of executing the JDBC * statement. */ @@ -625,7 +625,7 @@ private Publisher executeBatch( * {@link PreparedStatement#addBatch()}, * * @param jdbcStatement A JDBC statement - * @param batch A batch of bind values + * @param bindValues A set of bind values * @return A publisher that emits the {@code Results} of executing the * JDBC statement for each set of bind values in the {@code batch} */ diff --git a/src/main/java/oracle/r2dbc/impl/ReactiveJdbcAdapter.java b/src/main/java/oracle/r2dbc/impl/ReactiveJdbcAdapter.java index cdef83d..ec0c429 100755 --- a/src/main/java/oracle/r2dbc/impl/ReactiveJdbcAdapter.java +++ b/src/main/java/oracle/r2dbc/impl/ReactiveJdbcAdapter.java @@ -37,7 +37,6 @@ import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.util.function.Function; diff --git a/src/test/java/oracle/r2dbc/OracleTestKit.java b/src/test/java/oracle/r2dbc/OracleTestKit.java index 5ab4af3..04ba872 100755 --- a/src/test/java/oracle/r2dbc/OracleTestKit.java +++ b/src/test/java/oracle/r2dbc/OracleTestKit.java @@ -26,10 +26,11 @@ import io.r2dbc.spi.*; import io.r2dbc.spi.test.TestKit; -import oracle.r2dbc.util.OracleTestKitSupport; +import oracle.jdbc.datasource.OracleDataSource; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.jdbc.core.JdbcOperations; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.support.AbstractLobCreatingPreparedStatementCallback; import org.springframework.jdbc.support.lob.DefaultLobHandler; import org.springframework.jdbc.support.lob.LobCreator; @@ -46,7 +47,17 @@ import java.util.Collection; import java.util.function.Function; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static io.r2dbc.spi.ConnectionFactoryOptions.DATABASE; +import static io.r2dbc.spi.ConnectionFactoryOptions.DRIVER; +import static io.r2dbc.spi.ConnectionFactoryOptions.HOST; +import static io.r2dbc.spi.ConnectionFactoryOptions.PASSWORD; +import static io.r2dbc.spi.ConnectionFactoryOptions.PORT; +import static io.r2dbc.spi.ConnectionFactoryOptions.USER; +import static oracle.r2dbc.DatabaseConfig.host; +import static oracle.r2dbc.DatabaseConfig.password; +import static oracle.r2dbc.DatabaseConfig.port; +import static oracle.r2dbc.DatabaseConfig.serviceName; +import static oracle.r2dbc.DatabaseConfig.user; /** *

@@ -73,13 +84,38 @@ * @author harayuanwang, Michael-A-McMahon * @since 0.1.0 */ -public class OracleTestKit - extends OracleTestKitSupport implements TestKit { +public class OracleTestKit implements TestKit { + + private final JdbcOperations jdbcOperations; + { + try { + OracleDataSource dataSource = new oracle.jdbc.pool.OracleDataSource(); + dataSource.setURL(String.format("jdbc:oracle:thin:@%s:%d/%s", + host(), port(), serviceName())); + dataSource.setUser(user()); + dataSource.setPassword(password()); + this.jdbcOperations = new JdbcTemplate(dataSource); + } + catch (SQLException sqlException) { + throw new RuntimeException(sqlException); + } + } - static Mono close(Connection connection) { - return Mono.from(connection - .close()) - .then(Mono.empty()); + private final ConnectionFactory connectionFactory; + { + connectionFactory = ConnectionFactories.get( + ConnectionFactoryOptions.builder() + .option(DRIVER, "oracle") + .option(DATABASE, serviceName()) + .option(HOST, host()) + .option(PORT, port()) + .option(PASSWORD, password()) + .option(USER, user()) + .build()); + } + + public JdbcOperations getJdbcOperations() { + return jdbcOperations; } @Override @@ -108,17 +144,6 @@ public Integer getIdentifier(int index) { return index; } - @Override - public JdbcOperations getJdbcOperations() { - JdbcOperations jdbcOperations = CONFIG.getJDBCOperations(); - - if (jdbcOperations == null) { - throw new IllegalStateException("JdbcOperations not yet initialized"); - } - - return jdbcOperations; - } - /** * {@inheritDoc} *

@@ -402,7 +427,6 @@ protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQL .verifyComplete(); } - @Disabled("Compound statements are not supported by Oracle Database") @Test @Override @@ -418,6 +442,11 @@ public void savePoint() {} @Override public void savePointStartsTransaction() {} + static Mono close(Connection connection) { + return Mono.from(connection.close()) + .then(Mono.empty()); + } + } /* diff --git a/src/test/java/oracle/r2dbc/impl/OracleResultImplTest.java b/src/test/java/oracle/r2dbc/impl/OracleResultImplTest.java index 0121cfa..aad008b 100644 --- a/src/test/java/oracle/r2dbc/impl/OracleResultImplTest.java +++ b/src/test/java/oracle/r2dbc/impl/OracleResultImplTest.java @@ -30,7 +30,6 @@ import reactor.core.publisher.Mono; import reactor.core.publisher.Signal; -import java.util.Arrays; import java.util.List; import java.util.function.BiFunction; @@ -42,7 +41,6 @@ import static oracle.r2dbc.util.Awaits.awaitMany; import static oracle.r2dbc.util.Awaits.awaitNone; import static oracle.r2dbc.util.Awaits.awaitOne; -import static oracle.r2dbc.util.Awaits.awaitUpdate; import static org.junit.jupiter.api.Assertions.*; /** @@ -50,14 +48,14 @@ * {@link OracleResultImpl} implements behavior that is specified in it's * class and method level javadocs. */ -class OracleResultImplTest { +public class OracleResultImplTest { /** * Verifies the implementation of * {@link OracleResultImpl#getRowsUpdated()} */ @Test - void testGetRowsUpdated() { + public void testGetRowsUpdated() { Connection connection = Mono.from(sharedConnection()).block(connectTimeout()); try { @@ -178,7 +176,7 @@ void testGetRowsUpdated() { * {@link OracleResultImpl#map(BiFunction)} */ @Test - void testMap() { + public void testMap() { Connection connection = Mono.from(sharedConnection()).block(connectTimeout()); try { diff --git a/src/test/java/oracle/r2dbc/impl/OracleStatementImplTest.java b/src/test/java/oracle/r2dbc/impl/OracleStatementImplTest.java index d05811a..9707f4d 100644 --- a/src/test/java/oracle/r2dbc/impl/OracleStatementImplTest.java +++ b/src/test/java/oracle/r2dbc/impl/OracleStatementImplTest.java @@ -24,7 +24,6 @@ import io.r2dbc.spi.Connection; import io.r2dbc.spi.R2dbcException; import io.r2dbc.spi.Result; -import io.r2dbc.spi.Row; import io.r2dbc.spi.Statement; import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; @@ -34,7 +33,6 @@ import java.math.BigDecimal; import java.sql.RowId; import java.util.Collections; -import java.util.List; import static java.util.Arrays.asList; import static oracle.r2dbc.DatabaseConfig.connectTimeout; @@ -42,7 +40,6 @@ import static oracle.r2dbc.DatabaseConfig.sharedConnection; import static oracle.r2dbc.util.Awaits.awaitError; import static oracle.r2dbc.util.Awaits.awaitExecution; -import static oracle.r2dbc.util.Awaits.awaitMany; import static oracle.r2dbc.util.Awaits.awaitNone; import static oracle.r2dbc.util.Awaits.awaitOne; import static oracle.r2dbc.util.Awaits.awaitQuery; @@ -62,7 +59,7 @@ public class OracleStatementImplTest { * {@link OracleStatementImpl#bind(int, Object)} */ @Test - void testBindByIndex() { + public void testBindByIndex() { Connection connection = Mono.from(sharedConnection()).block(connectTimeout()); try { @@ -184,7 +181,7 @@ class UnsupportedType { * {@link OracleStatementImpl#bind(String, Object)} */ @Test - void testBindByName() { + public void testBindByName() { Connection connection = Mono.from(sharedConnection()).block(connectTimeout()); try { @@ -326,7 +323,7 @@ class UnsupportedType { * {@link OracleStatementImpl#bindNull(int, Class)} */ @Test - void testBindNullByIndex() { + public void testBindNullByIndex() { Connection connection = Mono.from(sharedConnection()).block(connectTimeout()); try { @@ -464,7 +461,7 @@ void testBindNullByIndex() { * {@link OracleStatementImpl#bindNull(String, Class)} */ @Test - void testBindNullByName() { + public void testBindNullByName() { Connection connection = Mono.from(sharedConnection()).block(connectTimeout()); try { @@ -633,7 +630,7 @@ void testBindNullByName() { * {@link OracleStatementImpl#add()} */ @Test - void testAdd() { + public void testAdd() { Connection connection = Mono.from(sharedConnection()).block(connectTimeout()); try { @@ -744,7 +741,7 @@ void testAdd() { * {@link OracleStatementImpl#execute()} */ @Test - void testExecute() { + public void testExecute() { Connection connection = Mono.from(sharedConnection()).block(connectTimeout()); try { @@ -849,7 +846,7 @@ void testExecute() { * {@link OracleStatementImpl#returnGeneratedValues(String...)} */ @Test - void testReturnGeneratedValues() { + public void testReturnGeneratedValues() { Connection connection = Mono.from(sharedConnection()).block(connectTimeout()); try { @@ -995,7 +992,7 @@ void testReturnGeneratedValues() { * {@link OracleStatementImpl#fetchSize(int) */ @Test - void testFetchSize() { + public void testFetchSize() { Connection connection = Mono.from(sharedConnection()).block(connectTimeout()); try { diff --git a/src/test/java/oracle/r2dbc/util/DatabaseConfigExtension.java b/src/test/java/oracle/r2dbc/util/DatabaseConfigExtension.java deleted file mode 100755 index 5c0c75d..0000000 --- a/src/test/java/oracle/r2dbc/util/DatabaseConfigExtension.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - Copyright (c) 2020, 2021, Oracle and/or its affiliates. - - This software is dual-licensed to you under the Universal Permissive License - (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License - 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose - either license. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package oracle.r2dbc.util; - -import oracle.jdbc.pool.OracleDataSource; -import oracle.r2dbc.DatabaseConfig; -import org.junit.jupiter.api.extension.BeforeAllCallback; -import org.junit.jupiter.api.extension.ExtensionContext; -import org.springframework.jdbc.core.JdbcOperations; -import org.springframework.jdbc.core.JdbcTemplate; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.sql.SQLException; -import java.util.Properties; - -/** - * JUnit Extension to establish an Oracle Database connection configuration - * during integration tests. - * - * @author harayuanwang - * @since 0.1.0 - */ -public final class DatabaseConfigExtension implements BeforeAllCallback { - private JdbcOperations jdbcOperations; - private OracleDataSource dataSource; - - @Override - public void beforeAll(ExtensionContext extensionContext) - throws IOException, SQLException { - initialize(); - } - - private void initialize() throws IOException, SQLException { - dataSource = new OracleDataSource(); - dataSource.setURL(String.format("jdbc:oracle:thin:@%s:%d/%s", - DatabaseConfig.host(), DatabaseConfig.port(), - DatabaseConfig.serviceName())); - dataSource.setUser(DatabaseConfig.user()); - dataSource.setPassword(DatabaseConfig.password()); - this.jdbcOperations = new JdbcTemplate(dataSource); - } - - public JdbcOperations getJDBCOperations() { - return this.jdbcOperations; - } - - public String getUsername() { - return DatabaseConfig.user(); - } - - public String getPassword() { - return DatabaseConfig.password(); - } - - public String getServiceName() { - return DatabaseConfig.serviceName(); - } - - public String getHost() { - return DatabaseConfig.host(); - } - - public int getPort() { - return DatabaseConfig.port(); - } -} - -/* - MODIFIED (MM/DD/YY) - harayuanwang 05/12/20 - Creation - */ diff --git a/src/test/java/oracle/r2dbc/util/OracleTestKitSupport.java b/src/test/java/oracle/r2dbc/util/OracleTestKitSupport.java deleted file mode 100755 index a9d58fb..0000000 --- a/src/test/java/oracle/r2dbc/util/OracleTestKitSupport.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - Copyright (c) 2020, 2021, Oracle and/or its affiliates. - - This software is dual-licensed to you under the Universal Permissive License - (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License - 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose - either license. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package oracle.r2dbc.util; - -import io.r2dbc.spi.ConnectionFactories; -import io.r2dbc.spi.ConnectionFactory; -import io.r2dbc.spi.ConnectionFactoryOptions; -import oracle.r2dbc.impl.OracleConnectionFactoryProviderImpl; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.extension.RegisterExtension; - -import static io.r2dbc.spi.ConnectionFactoryOptions.*; - -/** - * Initializes a {@link ConnectionFactory} with options specified - * by {@link DatabaseConfigExtension}. - * - * @author harayuanwang - * @since 0.1.0 - */ -public abstract class OracleTestKitSupport { - @RegisterExtension - protected static final DatabaseConfigExtension CONFIG = - new DatabaseConfigExtension(); - - protected static ConnectionFactory connectionFactory; - - @BeforeAll - static void beforeAll() { - ConnectionFactoryOptions options = builder().build(); - connectionFactory = ConnectionFactories.get(options); - } - - static ConnectionFactoryOptions.Builder builder() { - return ConnectionFactoryOptions.builder() - .option(DRIVER, new OracleConnectionFactoryProviderImpl().getDriver()) - .option(DATABASE, CONFIG.getServiceName()) - .option(HOST, CONFIG.getHost()) - .option(PORT, CONFIG.getPort()) - .option(PASSWORD, CONFIG.getPassword()) - .option(USER, CONFIG.getUsername()); - } -} - -/* - MODIFIED (MM/DD/YY) - harayuanwang 05/12/20 - Creation - */ From ab87d0f0893c9c987b89093202add17899b75958 Mon Sep 17 00:00:00 2001 From: Michael-A-McMahon Date: Sun, 7 Mar 2021 14:24:06 -0800 Subject: [PATCH 3/4] Add main method to print build info --- pom.xml | 29 ++++++++ src/main/java/oracle/r2dbc/impl/Main.java | 84 +++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 src/main/java/oracle/r2dbc/impl/Main.java diff --git a/pom.xml b/pom.xml index aded4b9..fe3c510 100755 --- a/pom.xml +++ b/pom.xml @@ -56,6 +56,35 @@ ${java.version} + + org.apache.maven.plugins + maven-jar-plugin + 2.1 + + + + Oracle R2DBC + + ${project.version} + + Oracle Corporation + + R2DBC - Reactive Relational Database Connectivity + + ${r2dbc.version} + + Pivotal Software, Inc + + + Oracle R2DBC ${project.version} compiled with JDK ${java.vm.version} from ${java.vm.vendor} on ${maven.build.timestamp} + + + oracle.r2dbc.impl.Main + + + + + org.apache.maven.plugins maven-deploy-plugin diff --git a/src/main/java/oracle/r2dbc/impl/Main.java b/src/main/java/oracle/r2dbc/impl/Main.java new file mode 100644 index 0000000..4a15342 --- /dev/null +++ b/src/main/java/oracle/r2dbc/impl/Main.java @@ -0,0 +1,84 @@ +/* + Copyright (c) 2020, 2021, Oracle and/or its affiliates. + + This software is dual-licensed to you under the Universal Permissive License + (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License + 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose + either license. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package oracle.r2dbc.impl; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Objects; +import java.util.jar.Manifest; + +/** + *

+ * A public class implementing a main method that may be executed from a + * command line. This class is specified as the Main-Class attribute in + * the META-INF/MANIFEST.MF of the Oracle R2DBC jar. + *

+ * The behavior implemented by this class may change between minor and patch + * version release updates. + *

+ * The following command, in + * which "x.y.z" is the semantic version number of the jar, + * executes the main method of this class: + *

+ *   java -jar oracle-r2dbc-x.y.z.jar
+ * 

+ * Since version 0.1.1, the main method is implemented to exit after printing + * a message to the standard output stream. The message includes the version + * numbers of the Oracle R2DBC Driver along with the JDK that compiled it. A + * timestamp captured at the moment when the jar was compiled is also included. + *

+ * + * @since 0.1.1 + * @author Michael-A-McMahon + */ +public final class Main { + + private Main() {/*This class has no instance fields*/} + + /** + * Prints information about this build of Oracle R2DBC. This method attempts + * to read a "Build-Info" attribute from META-INF/MANIFEST.MF. If the + * manifest is not available to the class loader, or if the manifest does + * not contain a Build-Info attribute, then this method prints a message + * indicating that build information can not be located. + * @param args ignored + * @throws IOException If the META-INF/MANIFEST.MF resource can not be read. + */ + public static void main(String[] args) throws IOException { + + InputStream manifestStream = + Main.class.getModule().getResourceAsStream("META-INF/MANIFEST.MF"); + + if (manifestStream == null) { + System.out.println("META-INF/MANIFEST.MF not found"); + return; + } + + try (manifestStream) { + System.out.println(Objects.requireNonNullElse( + new Manifest(manifestStream) + .getMainAttributes() + .getValue("Build-Info"), + "Build-Info is missing from the manifest")); + } + } +} From 28879f26e07aabdbb078a76d8db3340aed9f08a7 Mon Sep 17 00:00:00 2001 From: jean_de_lavarene Date: Fri, 12 Mar 2021 18:48:41 +0100 Subject: [PATCH 4/4] Change the module name --- src/main/java/module-info.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index af213c3..1c59cc7 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -24,7 +24,7 @@ * @provides io.r2dbc.spi.ConnectionFactoryProvider * @since 0.1.1 */ -module oracle.r2dbc { +module com.oracle.database.r2dbc { provides io.r2dbc.spi.ConnectionFactoryProvider with oracle.r2dbc.impl.OracleConnectionFactoryProviderImpl;