-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from graben/housekeeping
Remove some obsolete code for XADataSource handling
- Loading branch information
Showing
3 changed files
with
24 additions
and
86 deletions.
There are no files selected for viewing
67 changes: 0 additions & 67 deletions
67
...-core/src/main/java/dev/snowdrop/boot/narayana/core/jdbc/AbstractXADataSourceWrapper.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <a href="mailto:[email protected]">Gytis Trikleris</a> | ||
*/ | ||
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters