KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > access > TransactionConnectionDecorator


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19
20 package org.apache.cayenne.access;
21
22 import java.sql.CallableStatement JavaDoc;
23 import java.sql.Connection JavaDoc;
24 import java.sql.DatabaseMetaData JavaDoc;
25 import java.sql.PreparedStatement JavaDoc;
26 import java.sql.SQLException JavaDoc;
27 import java.sql.SQLWarning JavaDoc;
28 import java.sql.Savepoint JavaDoc;
29 import java.sql.Statement JavaDoc;
30 import java.util.Map JavaDoc;
31
32 /**
33  * A wrapper of a JDBC connection that is attached to a transaction. The behavior of this
34  * object to delegate all method calls to the underlying connection, except for the
35  * 'close' method that is implemented as noop in hope that a transaction originator will
36  * close the underlying Connection object.
37  *
38  * @since 1.2
39  * @author Andrus Adamchik
40  */

41 class TransactionConnectionDecorator implements Connection JavaDoc {
42
43     Connection JavaDoc connection;
44
45     TransactionConnectionDecorator(Connection JavaDoc connection) {
46         this.connection = connection;
47     }
48
49     // the only method that is NOT delegated...
50
public void close() throws SQLException JavaDoc {
51         // noop
52
}
53
54     public void clearWarnings() throws SQLException JavaDoc {
55         connection.clearWarnings();
56     }
57
58     public void commit() throws SQLException JavaDoc {
59         connection.commit();
60     }
61
62     public Statement JavaDoc createStatement() throws SQLException JavaDoc {
63         return connection.createStatement();
64     }
65
66     public Statement JavaDoc createStatement(
67             int resultSetType,
68             int resultSetConcurrency,
69             int resultSetHoldability) throws SQLException JavaDoc {
70         return connection.createStatement(
71                 resultSetType,
72                 resultSetConcurrency,
73                 resultSetHoldability);
74     }
75
76     public Statement JavaDoc createStatement(int resultSetType, int resultSetConcurrency)
77             throws SQLException JavaDoc {
78         return connection.createStatement(resultSetType, resultSetConcurrency);
79     }
80
81     public boolean getAutoCommit() throws SQLException JavaDoc {
82         return connection.getAutoCommit();
83     }
84
85     public String JavaDoc getCatalog() throws SQLException JavaDoc {
86         return connection.getCatalog();
87     }
88
89     public int getHoldability() throws SQLException JavaDoc {
90         return connection.getHoldability();
91     }
92
93     public DatabaseMetaData JavaDoc getMetaData() throws SQLException JavaDoc {
94         return connection.getMetaData();
95     }
96
97     public int getTransactionIsolation() throws SQLException JavaDoc {
98         return connection.getTransactionIsolation();
99     }
100
101     public Map JavaDoc getTypeMap() throws SQLException JavaDoc {
102         return connection.getTypeMap();
103     }
104
105     public SQLWarning JavaDoc getWarnings() throws SQLException JavaDoc {
106         return connection.getWarnings();
107     }
108
109     public boolean isClosed() throws SQLException JavaDoc {
110         return connection.isClosed();
111     }
112
113     public boolean isReadOnly() throws SQLException JavaDoc {
114         return connection.isReadOnly();
115     }
116
117     public String JavaDoc nativeSQL(String JavaDoc sql) throws SQLException JavaDoc {
118         return connection.nativeSQL(sql);
119     }
120
121     public CallableStatement JavaDoc prepareCall(
122             String JavaDoc sql,
123             int resultSetType,
124             int resultSetConcurrency,
125             int resultSetHoldability) throws SQLException JavaDoc {
126         return connection.prepareCall(
127                 sql,
128                 resultSetType,
129                 resultSetConcurrency,
130                 resultSetHoldability);
131     }
132
133     public CallableStatement JavaDoc prepareCall(
134             String JavaDoc sql,
135             int resultSetType,
136             int resultSetConcurrency) throws SQLException JavaDoc {
137         return connection.prepareCall(sql, resultSetType, resultSetConcurrency);
138     }
139
140     public CallableStatement JavaDoc prepareCall(String JavaDoc sql) throws SQLException JavaDoc {
141         return connection.prepareCall(sql);
142     }
143
144     public PreparedStatement JavaDoc prepareStatement(
145             String JavaDoc sql,
146             int resultSetType,
147             int resultSetConcurrency,
148             int resultSetHoldability) throws SQLException JavaDoc {
149         return connection.prepareStatement(
150                 sql,
151                 resultSetType,
152                 resultSetConcurrency,
153                 resultSetHoldability);
154     }
155
156     public PreparedStatement JavaDoc prepareStatement(
157             String JavaDoc sql,
158             int resultSetType,
159             int resultSetConcurrency) throws SQLException JavaDoc {
160         return connection.prepareStatement(sql, resultSetType, resultSetConcurrency);
161     }
162
163     public PreparedStatement JavaDoc prepareStatement(String JavaDoc sql, int autoGeneratedKeys)
164             throws SQLException JavaDoc {
165         return connection.prepareStatement(sql, autoGeneratedKeys);
166     }
167
168     public PreparedStatement JavaDoc prepareStatement(String JavaDoc sql, int[] columnIndexes)
169             throws SQLException JavaDoc {
170         return connection.prepareStatement(sql, columnIndexes);
171     }
172
173     public PreparedStatement JavaDoc prepareStatement(String JavaDoc sql, String JavaDoc[] columnNames)
174             throws SQLException JavaDoc {
175         return connection.prepareStatement(sql, columnNames);
176     }
177
178     public PreparedStatement JavaDoc prepareStatement(String JavaDoc sql) throws SQLException JavaDoc {
179         return connection.prepareStatement(sql);
180     }
181
182     public void releaseSavepoint(Savepoint JavaDoc savepoint) throws SQLException JavaDoc {
183         connection.releaseSavepoint(savepoint);
184     }
185
186     public void rollback() throws SQLException JavaDoc {
187         connection.rollback();
188     }
189
190     public void rollback(Savepoint JavaDoc savepoint) throws SQLException JavaDoc {
191         connection.rollback(savepoint);
192     }
193
194     public void setAutoCommit(boolean autoCommit) throws SQLException JavaDoc {
195         connection.setAutoCommit(autoCommit);
196     }
197
198     public void setCatalog(String JavaDoc catalog) throws SQLException JavaDoc {
199         connection.setCatalog(catalog);
200     }
201
202     public void setHoldability(int holdability) throws SQLException JavaDoc {
203         connection.setHoldability(holdability);
204     }
205
206     public void setReadOnly(boolean readOnly) throws SQLException JavaDoc {
207         connection.setReadOnly(readOnly);
208     }
209
210     public Savepoint JavaDoc setSavepoint() throws SQLException JavaDoc {
211         return connection.setSavepoint();
212     }
213
214     public Savepoint JavaDoc setSavepoint(String JavaDoc name) throws SQLException JavaDoc {
215         return connection.setSavepoint(name);
216     }
217
218     public void setTransactionIsolation(int level) throws SQLException JavaDoc {
219         connection.setTransactionIsolation(level);
220     }
221
222     public void setTypeMap(Map JavaDoc arg0) throws SQLException JavaDoc {
223         connection.setTypeMap(arg0);
224     }
225
226 }
227
Popular Tags