001: package com.completex.objective.components.persistency.transact.impl;
002:
003: import com.completex.objective.components.cache.Cache;
004: import com.completex.objective.components.log.Log;
005: import com.completex.objective.components.persistency.transact.Transaction;
006: import com.completex.objective.components.persistency.transact.PrimitiveTransactionManager;
007: import com.completex.objective.components.persistency.OdalPersistencyException;
008: import com.completex.objective.components.OdalRuntimeException;
009:
010: import java.sql.CallableStatement;
011: import java.sql.Connection;
012: import java.sql.PreparedStatement;
013: import java.sql.SQLException;
014:
015: /**
016: * PrimitiveTransactionManager implementation
017: *
018: * @author Gennady Krizhevsky
019: */
020: public class PrimitiveTransactionManagerImpl extends
021: AbstractTransactionManager implements
022: PrimitiveTransactionManager {
023: private Cache statementCache;
024: private Cache callCache;
025: private String connectionValidationStatement;
026:
027: /**
028: * @param statementCache Prepared statemets cache
029: * @param callCache Callable statements cache
030: * @param connectionValidationStatement
031: * @param log
032: */
033: public PrimitiveTransactionManagerImpl(Cache statementCache,
034: Cache callCache, String connectionValidationStatement,
035: Log log) {
036: super (log);
037: this .statementCache = statementCache;
038: this .callCache = callCache;
039: this .connectionValidationStatement = connectionValidationStatement;
040: }
041:
042: public Transaction begin(Connection connection) throws SQLException {
043: return new PrimitiveTransactionImpl(connection, getLogger(),
044: statementCache, callCache);
045: }
046:
047: public Transaction beginUnchecked(Connection connection) {
048: try {
049: return begin(connection);
050: } catch (SQLException e) {
051: throw new OdalRuntimeException(e.getClass().getName()
052: + ": " + e.getMessage());
053: }
054: }
055:
056: public Transaction begin() throws OdalPersistencyException {
057: throw new UnsupportedOperationException();
058: }
059:
060: protected Connection createConnection() {
061: throw new UnsupportedOperationException();
062: }
063:
064: protected void destroyConnection(Connection connection) {
065: }
066:
067: protected PreparedStatement prepareStatement(Connection connection,
068: String sql) throws SQLException {
069: throw new UnsupportedOperationException();
070: }
071:
072: protected void releaseStatement(Connection connection,
073: PreparedStatement statement) throws SQLException {
074: throw new UnsupportedOperationException();
075: }
076:
077: protected CallableStatement prepareCall(Connection connection,
078: String sql) throws SQLException {
079: throw new UnsupportedOperationException();
080: }
081:
082: protected String getConnectionValidationStatement() {
083: return connectionValidationStatement;
084: }
085:
086: protected void releaseBad(Connection connection) {
087: }
088:
089: public void releaseUnchecked(Transaction transaction) {
090: release(transaction);
091: }
092:
093: public void release(Transaction transaction) {
094: }
095:
096: public Transaction releaseTransaction(Transaction transaction) {
097: return super .releaseTransaction(transaction);
098: }
099:
100: public void shutdown() {
101: }
102:
103: public String toString() {
104: return super.toString();
105: }
106: }
|