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
020 import java.sql.Connection;
021
022 /**
023 * ConnectionFactory is responsible to lookup and release the
024 * connections used by the
025 * {@link org.apache.ojb.broker.accesslayer.ConnectionManagerIF}
026 * implementation.
027 *
028 * @version $Id: ConnectionFactory.java,v 1.1 2007-08-24 22:17:30 ewestfal Exp $
029 * @see org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl
030 * @see org.apache.ojb.broker.accesslayer.ConnectionFactoryNotPooledImpl
031 * @see org.apache.ojb.broker.accesslayer.ConnectionFactoryDBCPImpl
032 * @see org.apache.ojb.broker.accesslayer.ConnectionFactoryManagedImpl
033 */
034 public interface ConnectionFactory
035 {
036
037 /**
038 * Lookup a connection from the connection factory implementation.
039 */
040 Connection lookupConnection(JdbcConnectionDescriptor jcd) throws LookupException;
041
042 /**
043 * Release connection - CAUTION: Release every connection after use to avoid abandoned connections.
044 * Depending on the used implementation connection will be closed, returned to pool, ...
045 */
046 void releaseConnection(JdbcConnectionDescriptor jcd, Connection con);
047
048 /**
049 * Release all resources
050 * used by the implementing class (e.g. connection pool, ...)
051 * for the given connection descriptor.
052 */
053 void releaseAllResources();
054
055 }