| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ByPassConnection |
|
| 1.75;1.75 |
| 1 | package org.apache.ojb.broker.util.pooling; | |
| 2 | ||
| 3 | /* Copyright 2002-2005 The Apache Software Foundation | |
| 4 | * | |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 6 | * you may not use this file except in compliance with the License. | |
| 7 | * You may obtain a copy of the License at | |
| 8 | * | |
| 9 | * 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 | { | |
| 33 | private Logger log = LoggerFactory.getLogger(ByPassConnection.class); | |
| 34 | ||
| 35 | public ByPassConnection(Connection c) | |
| 36 | { | |
| 37 | super(c); | |
| 38 | this.activateConnection(); | |
| 39 | } | |
| 40 | ||
| 41 | /** | |
| 42 | * a no-op | |
| 43 | */ | |
| 44 | public void setAutoCommit(boolean autoCommit) throws SQLException | |
| 45 | { | |
| 46 | /* | |
| 47 | we ignore this. in managed environments it is not | |
| 48 | allowed to change autoCommit state | |
| 49 | */ | |
| 50 | if (log.isDebugEnabled()) log.debug("** we ignore setAutoCommit"); | |
| 51 | } | |
| 52 | ||
| 53 | /** | |
| 54 | * a no-op | |
| 55 | */ | |
| 56 | public void commit() throws SQLException | |
| 57 | { | |
| 58 | /* | |
| 59 | we ignore commit, cause this will do | |
| 60 | e.g. the J2EE environment for us, when using | |
| 61 | declarative or programmatic transaction in a j2ee container | |
| 62 | */ | |
| 63 | if (log.isDebugEnabled()) log.debug("** we ignore commit"); | |
| 64 | } | |
| 65 | ||
| 66 | /** | |
| 67 | * no-op | |
| 68 | */ | |
| 69 | public void rollback() throws SQLException | |
| 70 | { | |
| 71 | /* | |
| 72 | arminw: | |
| 73 | rollback of the connection should be done by the AppServer | |
| 74 | so we ignore this call too. in beans user should use ctx.setRollbackOnly | |
| 75 | method | |
| 76 | */ | |
| 77 | if (log.isDebugEnabled()) log.debug("** we ignore rollback, done by server"); | |
| 78 | } | |
| 79 | } |