Created
December 7, 2013 03:46
-
-
Save gbadner/7837050 to your computer and use it in GitHub Desktop.
Jta and Jdbc design for JdbcSession Proposal
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
interface JdbcSession { | |
TransactionCoordinator getTransactionCoordinator(); | |
Object accept(PreparedStatementQueryOperation operation); | |
// renamed to execute()? | |
void closeResources(PreparedStatementQueryOperation operation); | |
// needed??? | |
} | |
interface TransactionCoordinator { | |
... | |
Transaction getLocalTransaction(); | |
} | |
public class Transaction { | |
private PhysicalTransactionInflow physicalTransactionInflow; | |
... | |
public void begin() { | |
physicalTransactionInflow.begin(); | |
} | |
public void commit() { | |
physicalTransactionInflow.commit(); | |
} | |
public void rollback() { | |
physicalTransactionInflow.rollback(); | |
} | |
} | |
public class TransactionCoordinatorJdbcImpl implements TransactionCoordinator { | |
private JdbcSession jdbcSession; | |
private Transaction localTransaction; | |
public class PhysicalTransactionInflow { | |
private PhysicalJdbcTransaction physicalJdbcTransaction; | |
public void begin() { | |
physicalJdbcTransaction.begin(); | |
TransactionCoordinatorJdbcImpl.this.afterBegin(); | |
} | |
public void commit() { | |
TransactionCoordinatorJdbcImpl.this.beforeCompletion(); | |
physicalJdbcTransaction.commit(); | |
TransactionCoordinatorJdbcImpl.this.afterCompletion( true ); | |
} | |
pubic void rollback() { | |
// no beforeCompletion callbacks, consistent with JTA spec | |
physicalJdbcTransaction.rollback(); | |
TransactionCoordinatorJdbcImpl.this.afterCompletion( false ); | |
} | |
} | |
public Transaction getLocalTransaction() { | |
return localTransaction; | |
} | |
public void afterBegin() { | |
... | |
} | |
public void afterCompletion(boolean wasSuccessful) { | |
... | |
} | |
} | |
public class TransactionCoordinatorJtaImpl implements TransactionCoordinator { | |
private final JdbcSession jdbcSession; | |
private final Transaction localTransaction; | |
private final JtaPlatform jtaPlatform; | |
public class PhysicalTransactionInflow { | |
private PhysicalJtaTransaction physicalJtaTransaction; | |
public void begin() { | |
physicalJtaTransaction.begin(); | |
TransactionCoordinatorJtaImpl.this.afterBegin(); | |
} | |
public void commit() { | |
physicalJtaTransaction.commit(); | |
} | |
pubic void rollback() { | |
physicalJtaTransaction.rollback(); | |
} | |
} | |
public Transaction getLocalTransaction() { | |
return localTransaction; | |
} | |
public void afterBegin() { | |
} | |
public void afterCompletion(boolean wasSuccessful) { | |
} | |
} | |
public class PhysicalJtaTransaction { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment