mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Refactor rename TransactionManager methods (#2382)
This commit is contained in:
@@ -20,17 +20,17 @@ public interface SpiTransactionManager {
|
||||
/**
|
||||
* Return the main DataSource.
|
||||
*/
|
||||
DataSource getDataSource();
|
||||
DataSource dataSource();
|
||||
|
||||
/**
|
||||
* Return the read only DataSource (if defined).
|
||||
*/
|
||||
DataSource getReadOnlyDataSource();
|
||||
DataSource readOnlyDataSource();
|
||||
|
||||
/**
|
||||
* Return the currently active transaction (can be null).
|
||||
*/
|
||||
SpiTransaction getActive();
|
||||
SpiTransaction active();
|
||||
|
||||
/**
|
||||
* Push an externally managed transaction into scope (e.g. Spring managed transaction).
|
||||
@@ -60,6 +60,6 @@ public interface SpiTransactionManager {
|
||||
/**
|
||||
* Return a connection used for query plan collection.
|
||||
*/
|
||||
Connection getQueryPlanConnection() throws SQLException;
|
||||
Connection queryPlanConnection() throws SQLException;
|
||||
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public final class TransactionEvent implements Serializable {
|
||||
}
|
||||
if (eventTables != null && !eventTables.isEmpty()) {
|
||||
// notify cache with table based changes
|
||||
BeanDescriptorManager dm = manager.getBeanDescriptorManager();
|
||||
BeanDescriptorManager dm = manager.descriptorManager();
|
||||
for (TransactionEventTable.TableIUD tableIUD : eventTables.values()) {
|
||||
dm.cacheNotify(tableIUD, changeSet);
|
||||
}
|
||||
|
||||
@@ -347,12 +347,12 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
@Override
|
||||
public DataSource dataSource() {
|
||||
return transactionManager.getDataSource();
|
||||
return transactionManager.dataSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSource readOnlyDataSource() {
|
||||
return transactionManager.getReadOnlyDataSource();
|
||||
return transactionManager.readOnlyDataSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -686,7 +686,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
BeanDescriptor desc = descriptor(type);
|
||||
id = desc.convertId(id);
|
||||
PersistenceContext pc = null;
|
||||
SpiTransaction t = transactionManager.getActive();
|
||||
SpiTransaction t = transactionManager.active();
|
||||
if (t != null) {
|
||||
pc = t.getPersistenceContext();
|
||||
Object existing = desc.contextGet(pc, id);
|
||||
@@ -787,7 +787,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
@Override
|
||||
public SpiTransaction currentServerTransaction() {
|
||||
return transactionManager.getActive();
|
||||
return transactionManager.active();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -816,7 +816,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
@Override
|
||||
public Transaction currentTransaction() {
|
||||
return transactionManager.getActive();
|
||||
return transactionManager.active();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -836,7 +836,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
@Override
|
||||
public void endTransaction() {
|
||||
Transaction transaction = transactionManager.getInScope();
|
||||
Transaction transaction = transactionManager.inScope();
|
||||
if (transaction != null) {
|
||||
transaction.end();
|
||||
}
|
||||
@@ -2222,7 +2222,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
if (t != null) {
|
||||
return new ObtainedTransaction((SpiTransaction) t);
|
||||
}
|
||||
SpiTransaction trans = transactionManager.getActive();
|
||||
SpiTransaction trans = transactionManager.active();
|
||||
if (trans != null) {
|
||||
return new ObtainedTransaction(trans);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public final class CQueryPlanManager implements QueryPlanManager {
|
||||
}
|
||||
|
||||
private List<MetaQueryPlan> collectPlans(QueryPlanRequest request) {
|
||||
try (Connection connection = transactionManager.getQueryPlanConnection()) {
|
||||
try (Connection connection = transactionManager.queryPlanConnection()) {
|
||||
CQueryPlanRequest req = new CQueryPlanRequest(connection, request, plans.keySet().iterator());
|
||||
while (req.hasNext()) {
|
||||
req.nextCapture();
|
||||
|
||||
+2
-2
@@ -17,12 +17,12 @@ public class DefaultTransactionScopeManager extends TransactionScopeManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SpiTransaction getInScope() {
|
||||
public final SpiTransaction inScope() {
|
||||
return local.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiTransaction getActive() {
|
||||
public SpiTransaction active() {
|
||||
SpiTransaction t = local.get();
|
||||
if (t == null || !t.isActive()) {
|
||||
return null;
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ public final class ExternalTransactionScopeManager extends DefaultTransactionSco
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiTransaction getActive() {
|
||||
public SpiTransaction active() {
|
||||
return (SpiTransaction) externalManager.getCurrentTransaction();
|
||||
}
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
this.skipCacheAfterWrite = manager.isSkipCacheAfterWrite();
|
||||
this.batchMode = manager.isPersistBatch();
|
||||
this.batchOnCascadeMode = manager.isPersistBatchOnCascade();
|
||||
this.onQueryOnly = manager.getOnQueryOnly();
|
||||
this.onQueryOnly = manager.onQueryOnly();
|
||||
}
|
||||
|
||||
checkAutoCommit(connection);
|
||||
|
||||
+2
-2
@@ -54,7 +54,7 @@ public final class JtaTransactionManager implements ExternalTransactionManager {
|
||||
* Return the current dataSource taking into account multi-tenancy.
|
||||
*/
|
||||
private DataSource dataSource() {
|
||||
return transactionManager.getDataSource();
|
||||
return transactionManager.dataSource();
|
||||
}
|
||||
|
||||
private TransactionSynchronizationRegistry getSyncRegistry() {
|
||||
@@ -94,7 +94,7 @@ public final class JtaTransactionManager implements ExternalTransactionManager {
|
||||
}
|
||||
|
||||
// check current Ebean transaction
|
||||
SpiTransaction currentEbeanTransaction = scope.getInScope();
|
||||
SpiTransaction currentEbeanTransaction = scope.inScope();
|
||||
if (currentEbeanTransaction != null) {
|
||||
// NOT expecting this so log WARNING
|
||||
String msg = "JTA Transaction - no current txn BUT using current Ebean one " + currentEbeanTransaction.getId();
|
||||
|
||||
+3
-3
@@ -50,7 +50,7 @@ final class PostCommitProcessing {
|
||||
|
||||
this.clusterManager = clusterManager;
|
||||
this.manager = manager;
|
||||
this.serverName = manager.getServerName();
|
||||
this.serverName = manager.name();
|
||||
this.txnDocStoreMode = DocStoreMode.IGNORE;
|
||||
this.txnDocStoreBatchSize = 0;
|
||||
this.event = event;
|
||||
@@ -66,7 +66,7 @@ final class PostCommitProcessing {
|
||||
|
||||
this.clusterManager = clusterManager;
|
||||
this.manager = manager;
|
||||
this.serverName = manager.getServerName();
|
||||
this.serverName = manager.name();
|
||||
this.txnDocStoreMode = transaction.getDocStoreMode();
|
||||
this.txnDocStoreBatchSize = transaction.getDocStoreBatchSize();
|
||||
this.event = transaction.getEvent();
|
||||
@@ -162,7 +162,7 @@ final class PostCommitProcessing {
|
||||
}
|
||||
TransactionEventTable eventTables = event.getEventTables();
|
||||
if (eventTables != null && !eventTables.isEmpty()) {
|
||||
BulkEventListenerMap map = manager.getBulkEventListenerMap();
|
||||
BulkEventListenerMap map = manager.bulkEventListenerMap();
|
||||
for (TableIUD tableIUD : eventTables.values()) {
|
||||
map.process(tableIUD);
|
||||
}
|
||||
|
||||
+16
-16
@@ -181,22 +181,22 @@ public class TransactionManager implements SpiTransactionManager {
|
||||
* Return the current active transaction.
|
||||
*/
|
||||
@Override
|
||||
public final SpiTransaction getActive() {
|
||||
return scopeManager.getActive();
|
||||
public final SpiTransaction active() {
|
||||
return scopeManager.active();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current active transaction as a scoped transaction.
|
||||
*/
|
||||
private ScopedTransaction getActiveScoped() {
|
||||
return (ScopedTransaction) scopeManager.getActive();
|
||||
private ScopedTransaction activeScoped() {
|
||||
return (ScopedTransaction) scopeManager.active();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current transaction from thread local scope. Note that it may be inactive.
|
||||
*/
|
||||
public final SpiTransaction getInScope() {
|
||||
return scopeManager.getInScope();
|
||||
public final SpiTransaction inScope() {
|
||||
return scopeManager.inScope();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,11 +231,11 @@ public class TransactionManager implements SpiTransactionManager {
|
||||
return skipCacheAfterWrite;
|
||||
}
|
||||
|
||||
public final BeanDescriptorManager getBeanDescriptorManager() {
|
||||
public final BeanDescriptorManager descriptorManager() {
|
||||
return beanDescriptorManager;
|
||||
}
|
||||
|
||||
final BulkEventListenerMap getBulkEventListenerMap() {
|
||||
final BulkEventListenerMap bulkEventListenerMap() {
|
||||
return bulkEventListenerMap;
|
||||
}
|
||||
|
||||
@@ -271,29 +271,29 @@ public class TransactionManager implements SpiTransactionManager {
|
||||
return dbPlatformOnQueryOnly == null ? OnQueryOnly.COMMIT : dbPlatformOnQueryOnly;
|
||||
}
|
||||
|
||||
public final String getServerName() {
|
||||
public final String name() {
|
||||
return serverName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Connection getQueryPlanConnection() throws SQLException {
|
||||
public final Connection queryPlanConnection() throws SQLException {
|
||||
return dataSourceSupplier.getConnection(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DataSource getDataSource() {
|
||||
public final DataSource dataSource() {
|
||||
return dataSourceSupplier.getDataSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DataSource getReadOnlyDataSource() {
|
||||
public final DataSource readOnlyDataSource() {
|
||||
return dataSourceSupplier.getReadOnlyDataSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the type of behavior to use when closing a transaction that was used to query data only.
|
||||
*/
|
||||
final OnQueryOnly getOnQueryOnly() {
|
||||
final OnQueryOnly onQueryOnly() {
|
||||
return onQueryOnly;
|
||||
}
|
||||
|
||||
@@ -421,7 +421,7 @@ public class TransactionManager implements SpiTransactionManager {
|
||||
}
|
||||
|
||||
public final void externalModification(TransactionEventTable tableEvent) {
|
||||
SpiTransaction t = getActive();
|
||||
SpiTransaction t = active();
|
||||
if (t != null) {
|
||||
t.getEvent().add(tableEvent);
|
||||
} else {
|
||||
@@ -558,7 +558,7 @@ public class TransactionManager implements SpiTransactionManager {
|
||||
* Exit a scoped transaction (that can be inactive - already committed etc).
|
||||
*/
|
||||
public final void exitScopedTransaction(Object returnOrThrowable, int opCode) {
|
||||
SpiTransaction st = getInScope();
|
||||
SpiTransaction st = inScope();
|
||||
if (st instanceof ScopedTransaction) {
|
||||
// can be null for Supports as that can start as a 'No Transaction' and then
|
||||
// effectively be replaced by transactions inside the scope
|
||||
@@ -588,7 +588,7 @@ public class TransactionManager implements SpiTransactionManager {
|
||||
*/
|
||||
public final ScopedTransaction beginScopedTransaction(TxScope txScope) {
|
||||
txScope = initTxScope(txScope);
|
||||
ScopedTransaction txnContainer = getActiveScoped();
|
||||
ScopedTransaction txnContainer = activeScoped();
|
||||
|
||||
boolean setToScope;
|
||||
boolean nestedSavepoint;
|
||||
|
||||
+2
-2
@@ -16,12 +16,12 @@ public abstract class TransactionScopeManager implements SpiTransactionScopeMana
|
||||
/**
|
||||
* Return the current Transaction from internal Ebean scope.
|
||||
*/
|
||||
public abstract SpiTransaction getInScope();
|
||||
public abstract SpiTransaction inScope();
|
||||
|
||||
/**
|
||||
* Return the current Transaction potentially looking in external scope (like Spring).
|
||||
*/
|
||||
public abstract SpiTransaction getActive();
|
||||
public abstract SpiTransaction active();
|
||||
|
||||
/**
|
||||
* Set a new Transaction for this serverName and Thread.
|
||||
|
||||
Reference in New Issue
Block a user