001: package org.apache.ojb.broker.accesslayer;
002:
003: /* Copyright 2002-2005 The Apache Software Foundation
004: *
005: * Licensed under the Apache License, Version 2.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
019: import org.apache.ojb.broker.platforms.Platform;
020:
021: import java.sql.Connection;
022:
023: /**
024: * The connection manager handles the life cycle of a connection.
025: * Each {@link org.apache.ojb.broker.PersistenceBroker} instance
026: * use it's own connection manager.
027: */
028: public interface ConnectionManagerIF {
029:
030: /**
031: * Return the associated {@link org.apache.ojb.broker.metadata.JdbcConnectionDescriptor}.
032: */
033: JdbcConnectionDescriptor getConnectionDescriptor();
034:
035: /**
036: * Returns the supported {@link org.apache.ojb.broker.platforms.Platform}
037: * determined by the {@link org.apache.ojb.broker.metadata.JdbcConnectionDescriptor}.
038: * @see #getConnectionDescriptor
039: */
040: Platform getSupportedPlatform();
041:
042: /**
043: * checks if Connection conn is still open.
044: * returns true, if connection is open, else false.
045: */
046: boolean isAlive(Connection conn);
047:
048: /**
049: * Return a connection.
050: */
051: Connection getConnection() throws LookupException;
052:
053: /**
054: * Hold connection is in local transaction.
055: */
056: boolean isInLocalTransaction();
057:
058: /**
059: * Begin local transaction on the hold connection
060: * and set autocommit to false.
061: */
062: void localBegin();
063:
064: /**
065: * Commit the local transaction on the hold connection.
066: */
067: void localCommit();
068:
069: /**
070: * Rollback a changes on the hold connection.
071: */
072: void localRollback();
073:
074: /**
075: * Release the hold connection.
076: */
077: void releaseConnection();
078:
079: /**
080: * Sets the batch mode on (<code>true</code>) or
081: * off (<code>false</code>).
082: */
083: void setBatchMode(boolean mode);
084:
085: /**
086: * @return the batch mode.
087: */
088: boolean isBatchMode();
089:
090: /**
091: * Execute batch (if the batch mode where used).
092: */
093: void executeBatch();
094:
095: /**
096: * Execute batch if the number of statements in it
097: * exceeded the limit (if the batch mode where used).
098: */
099: void executeBatchIfNecessary();
100:
101: /**
102: * Clear batch (if the batch mode where used).
103: */
104: void clearBatch();
105:
106: }
|