01: package org.apache.ojb.broker.util.pooling;
02:
03: /* Copyright 2002-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: import org.apache.ojb.broker.util.logging.Logger;
19: import org.apache.ojb.broker.util.logging.LoggerFactory;
20: import org.apache.ojb.broker.util.WrappedConnection;
21:
22: import java.sql.Connection;
23: import java.sql.SQLException;
24:
25: /**
26: * Simple wrapper for connections that make some methods to no-op for
27: * use in managed environments.
28: *
29: * @author <a href="mailto:arminw@apache.org">Armin Waibel</a>
30: */
31: public class ByPassConnection extends WrappedConnection {
32: private Logger log = LoggerFactory
33: .getLogger(ByPassConnection.class);
34:
35: public ByPassConnection(Connection c) {
36: super (c);
37: this .activateConnection();
38: }
39:
40: /**
41: * a no-op
42: */
43: public void setAutoCommit(boolean autoCommit) throws SQLException {
44: /*
45: we ignore this. in managed environments it is not
46: allowed to change autoCommit state
47: */
48: if (log.isDebugEnabled())
49: log.debug("** we ignore setAutoCommit");
50: }
51:
52: /**
53: * a no-op
54: */
55: public void commit() throws SQLException {
56: /*
57: we ignore commit, cause this will do
58: e.g. the J2EE environment for us, when using
59: declarative or programmatic transaction in a j2ee container
60: */
61: if (log.isDebugEnabled())
62: log.debug("** we ignore commit");
63: }
64:
65: /**
66: * no-op
67: */
68: public void rollback() throws SQLException {
69: /*
70: arminw:
71: rollback of the connection should be done by the AppServer
72: so we ignore this call too. in beans user should use ctx.setRollbackOnly
73: method
74: */
75: if (log.isDebugEnabled())
76: log.debug("** we ignore rollback, done by server");
77: }
78: }
|