diff --git a/narayana-spring-boot-core/src/main/java/dev/snowdrop/boot/narayana/core/jdbc/AbstractXADataSourceWrapper.java b/narayana-spring-boot-core/src/main/java/dev/snowdrop/boot/narayana/core/jdbc/AbstractXADataSourceWrapper.java
deleted file mode 100644
index 4b408b69..00000000
--- a/narayana-spring-boot-core/src/main/java/dev/snowdrop/boot/narayana/core/jdbc/AbstractXADataSourceWrapper.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2020 Red Hat, Inc, and individual contributors.
- *
- * 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
- *
- * http://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 dev.snowdrop.boot.narayana.core.jdbc;
-
-import javax.sql.DataSource;
-import javax.sql.XADataSource;
-
-import com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule;
-import com.arjuna.ats.jta.recovery.XAResourceRecoveryHelper;
-import dev.snowdrop.boot.narayana.core.properties.RecoveryCredentialsProperties;
-import org.springframework.boot.jdbc.XADataSourceWrapper;
-
-/**
- * An abstract {@link XADataSourceWrapper} implementation which handles {@link XAResourceRecoveryHelper} creation and
- * registration. It delegates the actual {@link XADataSource} wrapping to its subclasses.
- *
- * @author Gytis Trikleris
- */
-public abstract class AbstractXADataSourceWrapper implements XADataSourceWrapper {
-
- private final XARecoveryModule xaRecoveryModule;
- private final RecoveryCredentialsProperties recoveryCredentials;
-
- protected AbstractXADataSourceWrapper(XARecoveryModule xaRecoveryModule, RecoveryCredentialsProperties recoveryCredentials) {
- this.xaRecoveryModule = xaRecoveryModule;
- this.recoveryCredentials = recoveryCredentials;
- }
-
- protected abstract DataSource wrapDataSourceInternal(XADataSource dataSource) throws Exception;
-
- /**
- * Register newly created recovery helper with the {@link XARecoveryModule} and delegate data source wrapping.
- *
- * @param dataSource {@link XADataSource} that needs to be wrapped.
- * @return wrapped data source
- * @throws Exception in case data source wrapping has failed
- */
- @Override
- public DataSource wrapDataSource(XADataSource dataSource) throws Exception {
- XAResourceRecoveryHelper recoveryHelper = getRecoveryHelper(dataSource);
- this.xaRecoveryModule.addXAResourceRecoveryHelper(recoveryHelper);
- return wrapDataSourceInternal(dataSource);
- }
-
- private XAResourceRecoveryHelper getRecoveryHelper(XADataSource dataSource) {
- if (this.recoveryCredentials.isValid()) {
- return new DataSourceXAResourceRecoveryHelper(dataSource, this.recoveryCredentials.getUser(),
- this.recoveryCredentials.getPassword());
- }
- return new DataSourceXAResourceRecoveryHelper(dataSource);
- }
-
-}
diff --git a/narayana-spring-boot-core/src/main/java/dev/snowdrop/boot/narayana/core/jdbc/GenericXADataSourceWrapper.java b/narayana-spring-boot-core/src/main/java/dev/snowdrop/boot/narayana/core/jdbc/GenericXADataSourceWrapper.java
index bdd1be3d..7555b71d 100644
--- a/narayana-spring-boot-core/src/main/java/dev/snowdrop/boot/narayana/core/jdbc/GenericXADataSourceWrapper.java
+++ b/narayana-spring-boot-core/src/main/java/dev/snowdrop/boot/narayana/core/jdbc/GenericXADataSourceWrapper.java
@@ -20,15 +20,20 @@
import javax.sql.XADataSource;
import com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule;
+import com.arjuna.ats.jta.recovery.XAResourceRecoveryHelper;
import dev.snowdrop.boot.narayana.core.properties.RecoveryCredentialsProperties;
+import org.springframework.boot.jdbc.XADataSourceWrapper;
/**
- * {@link AbstractXADataSourceWrapper} implementation that uses {@link NarayanaDataSource} to wrap an
- * {@link XADataSource}.
+ * An {@link XADataSourceWrapper} implementation which handles {@link XAResourceRecoveryHelper} creation and
+ * registration. It delegates the actual {@link XADataSource} wrapping to its subclass {@link NarayanaDataSource}.
*
* @author Gytis Trikleris
*/
-public class GenericXADataSourceWrapper extends AbstractXADataSourceWrapper {
+public class GenericXADataSourceWrapper implements XADataSourceWrapper {
+
+ private final XARecoveryModule xaRecoveryModule;
+ private final RecoveryCredentialsProperties recoveryCredentials;
/**
* Create a new {@link GenericXADataSourceWrapper} instance.
@@ -46,18 +51,29 @@ public GenericXADataSourceWrapper(XARecoveryModule xaRecoveryModule) {
* @param recoveryCredentials credentials for recovery helper
*/
public GenericXADataSourceWrapper(XARecoveryModule xaRecoveryModule, RecoveryCredentialsProperties recoveryCredentials) {
- super(xaRecoveryModule, recoveryCredentials);
+ this.xaRecoveryModule = xaRecoveryModule;
+ this.recoveryCredentials = recoveryCredentials;
}
/**
- * Wrap provided {@link XADataSource} with an instance of {@link NarayanaDataSource}.
+ * Register newly created recovery helper with the {@link XARecoveryModule} and delegate data source wrapping.
*
- * @param dataSource data source that needs to be wrapped.
- * @return wrapped data source.
+ * @param dataSource {@link XADataSource} that needs to be wrapped.
+ * @return wrapped data source
+ * @throws Exception in case data source wrapping has failed
*/
@Override
- protected DataSource wrapDataSourceInternal(XADataSource dataSource) {
+ public DataSource wrapDataSource(XADataSource dataSource) throws Exception {
+ XAResourceRecoveryHelper recoveryHelper = getRecoveryHelper(dataSource);
+ this.xaRecoveryModule.addXAResourceRecoveryHelper(recoveryHelper);
return new NarayanaDataSource(dataSource);
}
+ private XAResourceRecoveryHelper getRecoveryHelper(XADataSource dataSource) {
+ if (this.recoveryCredentials.isValid()) {
+ return new DataSourceXAResourceRecoveryHelper(dataSource, this.recoveryCredentials.getUser(),
+ this.recoveryCredentials.getPassword());
+ }
+ return new DataSourceXAResourceRecoveryHelper(dataSource);
+ }
}
diff --git a/narayana-spring-boot-core/src/test/java/dev/snowdrop/boot/narayana/core/jdbc/NarayanaDataSourceTests.java b/narayana-spring-boot-core/src/test/java/dev/snowdrop/boot/narayana/core/jdbc/NarayanaDataSourceTests.java
index ff23aed9..65c3ba4f 100644
--- a/narayana-spring-boot-core/src/test/java/dev/snowdrop/boot/narayana/core/jdbc/NarayanaDataSourceTests.java
+++ b/narayana-spring-boot-core/src/test/java/dev/snowdrop/boot/narayana/core/jdbc/NarayanaDataSourceTests.java
@@ -27,7 +27,6 @@
import javax.sql.XADataSource;
import com.arjuna.ats.internal.jdbc.ConnectionImple;
-import com.arjuna.ats.jdbc.TransactionalDriver;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -92,10 +91,6 @@ void shouldGetConnectionAndCommit() throws SQLException {
given(mockXaConnection.getConnection()).willReturn(mockConnection);
given(this.mockXaDataSource.getXAConnection()).willReturn(mockXaConnection);
- // TODO properties not used
- Properties properties = new Properties();
- properties.put(TransactionalDriver.XADataSource, this.mockXaDataSource);
-
Connection connection = this.dataSourceBean.getConnection();
assertThat(connection).isInstanceOf(ConnectionImple.class);
@@ -125,12 +120,6 @@ void shouldGetConnectionAndCommitWithCredentials() throws IOException, SQLExcept
given(mockXaConnection.getConnection()).willReturn(mockConnection);
given(this.mockXaDataSource.getXAConnection(authProperties.getProperty("username"), authProperties.getProperty("username"))).willReturn(mockXaConnection);
- // TODO properties not used
- Properties properties = new Properties();
- properties.put(TransactionalDriver.XADataSource, this.mockXaDataSource);
- properties.put(TransactionalDriver.userName, authProperties.getProperty("username"));
- properties.put(TransactionalDriver.password, authProperties.getProperty("username"));
-
Connection connection = this.dataSourceBean.getConnection(authProperties.getProperty("username"), authProperties.getProperty("username"));
assertThat(connection).isInstanceOf(ConnectionImple.class);