01: package com.completex.objective.components.persistency.transact;
02:
03: import java.sql.Connection;
04: import java.sql.SQLException;
05:
06: /**
07: * PrimitiveTransactionManager is very specific implementation of Transaction Manager.
08: * It is created for the situations where you have absolutely no control over the
09: * way connections get created and destroyed.
10: * Instead of begin() and beginUnchecked() use begin(Connection connection) and
11: * beginUnchecked(Connection connection), respectively. Usual begin() and beginUnchecked()
12: * should throw RuntimeException.
13: *
14: * @author Gennady Krizhevsky
15: */
16: public interface PrimitiveTransactionManager extends TransactionManager {
17:
18: public static final PrimitiveTransactionManager NULL_TRANSACTION_MANAGER = new PrimitiveTransactionManager.NullTransactionManager();
19:
20: /**
21: * Creates a transaction wrapper around connection.
22: *
23: * @param connection external connection
24: * @return new Transaction
25: * @throws java.sql.SQLException
26: */
27: Transaction begin(Connection connection) throws SQLException;
28:
29: /**
30: * @param connection external connection
31: * @return new Transaction
32: * @throws com.completex.objective.components.OdalRuntimeException if database error happens
33: */
34: Transaction beginUnchecked(Connection connection);
35:
36: /**
37: * Null TransactionManager implementation
38: */
39: static class NullTransactionManager extends
40: TransactionManager.NullTransactionManager implements
41: PrimitiveTransactionManager {
42: public Transaction begin() throws SQLException {
43: throw new UnsupportedOperationException();
44: }
45:
46: public Transaction begin(Connection connection)
47: throws SQLException {
48: return Transaction.NULL_TRANSACTION;
49: }
50:
51: public Transaction beginUnchecked(Connection connection) {
52: return Transaction.NULL_TRANSACTION;
53: }
54:
55: }
56:
57: }
|