01: /*
02: * Copyright 2004 Clinton Begin
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package com.ibatis.sqlmap.engine.transaction.user;
17:
18: import com.ibatis.common.jdbc.logging.ConnectionLogProxy;
19: import com.ibatis.common.logging.Log;
20: import com.ibatis.common.logging.LogFactory;
21: import com.ibatis.sqlmap.engine.transaction.Transaction;
22: import com.ibatis.sqlmap.engine.transaction.TransactionException;
23:
24: import java.sql.Connection;
25: import java.sql.SQLException;
26:
27: public class UserProvidedTransaction implements Transaction {
28:
29: private static final Log connectionLog = LogFactory
30: .getLog(Connection.class);
31:
32: private Connection connection;
33:
34: public UserProvidedTransaction(Connection connection) {
35: if (connectionLog.isDebugEnabled()) {
36: this .connection = ConnectionLogProxy
37: .newInstance(connection);
38: } else {
39: this .connection = connection;
40: }
41: }
42:
43: public void commit() throws SQLException, TransactionException {
44: connection.commit();
45: }
46:
47: public void rollback() throws SQLException, TransactionException {
48: connection.rollback();
49: }
50:
51: public void close() throws SQLException, TransactionException {
52: connection.close();
53: }
54:
55: public Connection getConnection() throws SQLException,
56: TransactionException {
57: return connection;
58: }
59:
60: }
|