-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 #31729 from zhfeng/issue_31066_narayana_jdbc_store
Support JDBC ObjectStore in narayana-jta extension
- Loading branch information
Showing
16 changed files
with
370 additions
and
55 deletions.
There are no files selected for viewing
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
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
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
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
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
6 changes: 6 additions & 0 deletions
6
...s/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/ObjectStoreType.java
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.quarkus.narayana.jta.runtime; | ||
|
||
public enum ObjectStoreType { | ||
File_System, | ||
JDBC | ||
} |
80 changes: 80 additions & 0 deletions
80
...narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/QuarkusDataSource.java
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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package io.quarkus.narayana.jta.runtime; | ||
|
||
import java.io.PrintWriter; | ||
import java.sql.Connection; | ||
import java.sql.SQLException; | ||
import java.sql.SQLFeatureNotSupportedException; | ||
import java.util.Optional; | ||
import java.util.logging.Logger; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import jakarta.enterprise.inject.literal.NamedLiteral; | ||
|
||
import io.quarkus.arc.Arc; | ||
|
||
public class QuarkusDataSource implements DataSource { | ||
private final Optional<String> dsName; | ||
private volatile DataSource datasource; | ||
|
||
public QuarkusDataSource(Optional<String> dsName) { | ||
this.dsName = dsName; | ||
} | ||
|
||
private DataSource getDataSource() { | ||
if (datasource == null) { | ||
if (dsName.isEmpty()) { | ||
datasource = Arc.container().instance(DataSource.class).get(); | ||
} else { | ||
datasource = Arc.container().instance(DataSource.class, NamedLiteral.of(dsName.get())).get(); | ||
} | ||
} | ||
|
||
return datasource; | ||
} | ||
|
||
@Override | ||
public Connection getConnection() throws SQLException { | ||
return getDataSource().getConnection(); | ||
} | ||
|
||
@Override | ||
public Connection getConnection(final String user, final String passwd) throws SQLException { | ||
return getDataSource().getConnection(user, passwd); | ||
} | ||
|
||
@Override | ||
public PrintWriter getLogWriter() throws SQLException { | ||
return getDataSource().getLogWriter(); | ||
} | ||
|
||
@Override | ||
public void setLogWriter(final PrintWriter writer) throws SQLException { | ||
getDataSource().setLogWriter(writer); | ||
} | ||
|
||
@Override | ||
public void setLoginTimeout(final int timeout) throws SQLException { | ||
getDataSource().setLoginTimeout(timeout); | ||
} | ||
|
||
@Override | ||
public int getLoginTimeout() throws SQLException { | ||
return getDataSource().getLoginTimeout(); | ||
} | ||
|
||
@Override | ||
public Logger getParentLogger() throws SQLFeatureNotSupportedException { | ||
return getDataSource().getParentLogger(); | ||
} | ||
|
||
@Override | ||
public <T> T unwrap(final Class<T> aClass) throws SQLException { | ||
return getDataSource().unwrap(aClass); | ||
} | ||
|
||
@Override | ||
public boolean isWrapperFor(final Class<?> aClass) throws SQLException { | ||
return getDataSource().isWrapperFor(aClass); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...ana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/QuarkusRecoveryService.java
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.quarkus.narayana.jta.runtime; | ||
|
||
import com.arjuna.ats.jbossatx.jta.RecoveryManagerService; | ||
|
||
public class QuarkusRecoveryService { | ||
private static RecoveryManagerService recoveryManagerService; | ||
|
||
public static RecoveryManagerService getInstance() { | ||
if (recoveryManagerService == null) { | ||
recoveryManagerService = new RecoveryManagerService(); | ||
} | ||
return recoveryManagerService; | ||
} | ||
|
||
private QuarkusRecoveryService() { | ||
} | ||
} |
Oops, something went wrong.