KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibatis > sqlmap > engine > transaction > user > UserProvidedTransaction


1 /*
2  * Copyright 2004 Clinton Begin
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
25 import java.sql.SQLException JavaDoc;
26
27 public class UserProvidedTransaction implements Transaction {
28
29   private static final Log connectionLog = LogFactory.getLog(Connection JavaDoc.class);
30
31   private Connection JavaDoc connection;
32
33   public UserProvidedTransaction(Connection JavaDoc connection) {
34     if (connectionLog.isDebugEnabled()) {
35       this.connection = ConnectionLogProxy.newInstance(connection);
36     } else {
37       this.connection = connection;
38     }
39   }
40
41   public void commit() throws SQLException JavaDoc, TransactionException {
42     connection.commit();
43   }
44
45   public void rollback() throws SQLException JavaDoc, TransactionException {
46     connection.rollback();
47   }
48
49   public void close() throws SQLException JavaDoc, TransactionException {
50     connection.close();
51   }
52
53   public Connection JavaDoc getConnection() throws SQLException JavaDoc, TransactionException {
54     return connection;
55   }
56
57 }
58
Popular Tags