Save This Page
Home » Hibernate-3.3.2.GA » org.hibernate » connection » [javadoc | source]
    1   /*
    2    * Hibernate, Relational Persistence for Idiomatic Java
    3    *
    4    * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
    5    * indicated by the @author tags or express copyright attribution
    6    * statements applied by the authors.  All third-party contributions are
    7    * distributed under license by Red Hat Middleware LLC.
    8    *
    9    * This copyrighted material is made available to anyone wishing to use, modify,
   10    * copy, or redistribute it subject to the terms and conditions of the GNU
   11    * Lesser General Public License, as published by the Free Software Foundation.
   12    *
   13    * This program is distributed in the hope that it will be useful,
   14    * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   15    * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
   16    * for more details.
   17    *
   18    * You should have received a copy of the GNU Lesser General Public License
   19    * along with this distribution; if not, write to:
   20    * Free Software Foundation, Inc.
   21    * 51 Franklin Street, Fifth Floor
   22    * Boston, MA  02110-1301  USA
   23    *
   24    */
   25   package org.hibernate.connection;
   26   import java.sql.Connection;
   27   import java.sql.SQLException;
   28   import java.util.Properties;
   29   
   30   import org.hibernate.HibernateException;
   31   
   32   /**
   33    * A strategy for obtaining JDBC connections.
   34    * <br><br>
   35    * Implementors might also implement connection pooling.<br>
   36    * <br>
   37    * The <tt>ConnectionProvider</tt> interface is not intended to be
   38    * exposed to the application. Instead it is used internally by
   39    * Hibernate to obtain connections.<br>
   40    * <br>
   41    * Implementors should provide a public default constructor.
   42    *
   43    * @see ConnectionProviderFactory
   44    * @author Gavin King
   45    */
   46   public interface ConnectionProvider {
   47   	/**
   48   	 * Initialize the connection provider from given properties.
   49   	 * @param props <tt>SessionFactory</tt> properties
   50   	 */
   51   	public void configure(Properties props) throws HibernateException;
   52   	/**
   53   	 * Grab a connection, with the autocommit mode specified by
   54   	 * <tt>hibernate.connection.autocommit</tt>.
   55   	 * @return a JDBC connection
   56   	 * @throws SQLException
   57   	 */
   58   	public Connection getConnection() throws SQLException;
   59   	/**
   60   	 * Dispose of a used connection.
   61   	 * @param conn a JDBC connection
   62   	 * @throws SQLException
   63   	 */
   64   	public void closeConnection(Connection conn) throws SQLException;
   65   
   66   	/**
   67   	 * Release all resources held by this provider. JavaDoc requires a second sentence.
   68   	 * @throws HibernateException
   69   	 */
   70   	public void close() throws HibernateException;
   71   
   72   	/**
   73   	 * Does this connection provider support aggressive release of JDBC
   74   	 * connections and re-acquistion of those connections (if need be) later?
   75   	 * <p/>
   76   	 * This is used in conjunction with {@link org.hibernate.cfg.Environment.RELEASE_CONNECTIONS}
   77   	 * to aggressively release JDBC connections.  However, the configured ConnectionProvider
   78   	 * must support re-acquisition of the same underlying connection for that semantic to work.
   79   	 * <p/>
   80   	 * Typically, this is only true in managed environments where a container
   81   	 * tracks connections by transaction or thread.
   82   	 *
   83   	 * Note that JTA semantic depends on the fact that the underlying connection provider does
   84   	 * support aggressive release.
   85   	 */
   86   	public boolean supportsAggressiveRelease();
   87   }
   88   
   89   
   90   
   91   
   92   
   93   
   94   

Save This Page
Home » Hibernate-3.3.2.GA » org.hibernate » connection » [javadoc | source]