From: <one...@us...> - 2003-02-22 06:42:14
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/connection In directory sc8-pr-cvs1:/tmp/cvs-serv17247/sf/hibernate/connection Modified Files: C3P0ConnectionProvider.java ConnectionProvider.java DBCPConnectionProvider.java DatasourceConnectionProvider.java DriverManagerConnectionProvider.java UserSuppliedConnectionProvider.java Log Message: fixed a problem with HibernateService added convenience createBlob() improved some logging added SessionFactory.close() Index: C3P0ConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/connection/C3P0ConnectionProvider.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** C3P0ConnectionProvider.java 26 Jan 2003 01:33:35 -0000 1.5 --- C3P0ConnectionProvider.java 22 Feb 2003 06:42:07 -0000 1.6 *************** *** 118,121 **** --- 118,125 ---- } + public void close() { + // no API for closing a c3p0 pool + } + } Index: ConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/connection/ConnectionProvider.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ConnectionProvider.java 5 Jan 2003 02:11:20 -0000 1.3 --- ConnectionProvider.java 22 Feb 2003 06:42:07 -0000 1.4 *************** *** 42,45 **** --- 42,51 ---- */ public boolean isStatementCache(); + + /** + * Release all resources held by this provider. + * @throws SQLException + */ + public void close() throws HibernateException; } Index: DBCPConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/connection/DBCPConnectionProvider.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DBCPConnectionProvider.java 26 Jan 2003 01:33:35 -0000 1.5 --- DBCPConnectionProvider.java 22 Feb 2003 06:42:07 -0000 1.6 *************** *** 30,35 **** public class DBCPConnectionProvider implements ConnectionProvider { - private DataSource ds; private Integer isolation; private static final Log log = LogFactory.getLog(DBCPConnectionProvider.class); --- 30,37 ---- public class DBCPConnectionProvider implements ConnectionProvider { private Integer isolation; + private DataSource ds; + private KeyedObjectPoolFactory statementPool; + private ObjectPool connectionPool; private static final Log log = LogFactory.getLog(DBCPConnectionProvider.class); *************** *** 88,92 **** // We'll need a ObjectPool that serves as the // actual pool of connections. ! ObjectPool connectionPool = new GenericObjectPool( null, Integer.parseInt( props.getProperty(Environment.DBCP_MAXACTIVE) ), --- 90,94 ---- // We'll need a ObjectPool that serves as the // actual pool of connections. ! connectionPool = new GenericObjectPool( null, Integer.parseInt( props.getProperty(Environment.DBCP_MAXACTIVE) ), *************** *** 98,102 **** // We'll need a KeyedObjectPoolFactory that serves as the // actual pool of prepared statements. ! KeyedObjectPoolFactory statementPool = new GenericKeyedObjectPoolFactory( null, Integer.parseInt( props.getProperty(Environment.DBCP_PS_MAXACTIVE) ), --- 100,104 ---- // We'll need a KeyedObjectPoolFactory that serves as the // actual pool of prepared statements. ! statementPool = new GenericKeyedObjectPoolFactory( null, Integer.parseInt( props.getProperty(Environment.DBCP_PS_MAXACTIVE) ), *************** *** 139,142 **** --- 141,156 ---- } + /** + * @see net.sf.hibernate.connection.ConnectionProvider#close() + */ + public void close() throws HibernateException { + try { + connectionPool.close(); + } + catch (Exception e) { + throw new HibernateException("could not close DBCP pool", e); + } + } + } Index: DatasourceConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/connection/DatasourceConnectionProvider.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DatasourceConnectionProvider.java 26 Jan 2003 01:33:35 -0000 1.4 --- DatasourceConnectionProvider.java 22 Feb 2003 06:42:07 -0000 1.5 *************** *** 12,15 **** --- 12,16 ---- import java.sql.*; + import javax.sql.DataSource; *************** *** 78,81 **** --- 79,85 ---- } + public void close() { + } + } Index: DriverManagerConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/connection/DriverManagerConnectionProvider.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DriverManagerConnectionProvider.java 26 Jan 2003 01:33:35 -0000 1.6 --- DriverManagerConnectionProvider.java 22 Feb 2003 06:42:08 -0000 1.7 *************** *** 136,141 **** protected void finalize() { ! log.info("cleaning up dereferenced connection pool: " + url); Iterator iter = pool.iterator(); --- 136,145 ---- protected void finalize() { + close(); + } + + public void close() { ! log.info("cleaning up connection pool: " + url); Iterator iter = pool.iterator(); *************** *** 148,153 **** } } } ! } --- 152,159 ---- } } + pool.clear(); + } ! } Index: UserSuppliedConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/connection/UserSuppliedConnectionProvider.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** UserSuppliedConnectionProvider.java 5 Jan 2003 02:11:20 -0000 1.3 --- UserSuppliedConnectionProvider.java 22 Feb 2003 06:42:08 -0000 1.4 *************** *** 46,49 **** --- 46,52 ---- } + public void close() { + } + } |