Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Connection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9573 Modified Files: ConnectionProvider.cs ConnectionProviderFactory.cs DriverConnectionProvider.cs IConnectionProvider.cs UserSuppliedConnectionProvider.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: IConnectionProvider.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Connection/IConnectionProvider.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IConnectionProvider.cs 18 Jun 2004 13:59:05 -0000 1.5 --- IConnectionProvider.cs 31 Dec 2004 16:46:43 -0000 1.6 *************** *** 1,9 **** - using System; - using System.Data; using System.Collections; ! using NHibernate.Driver; ! namespace NHibernate.Connection { /// <summary> --- 1,7 ---- using System.Collections; ! using System.Data; using NHibernate.Driver; ! namespace NHibernate.Connection { /// <summary> *************** *** 15,21 **** /// a public default constructor. /// </remarks> ! public interface IConnectionProvider { - /// <summary> /// The Driver this ConnectionProvider should use to communicate with the .NET Data Provider --- 13,18 ---- /// a public default constructor. /// </remarks> ! public interface IConnectionProvider { /// <summary> /// The Driver this ConnectionProvider should use to communicate with the .NET Data Provider *************** *** 23,27 **** /// <value></value> /// <remarks></remarks> ! IDriver Driver {get;} /// <summary> --- 20,24 ---- /// <value></value> /// <remarks></remarks> ! IDriver Driver { get; } /// <summary> *************** *** 29,33 **** /// </summary> /// <param name="settings">The connection provider settings</param> ! void Configure(IDictionary settings); /// <summary> --- 26,30 ---- /// </summary> /// <param name="settings">The connection provider settings</param> ! void Configure( IDictionary settings ); /// <summary> *************** *** 41,45 **** /// </summary> /// <param name="conn">An ADO.NET connection</param> ! void CloseConnection(IDbConnection conn); /// <summary> --- 38,42 ---- /// </summary> /// <param name="conn">An ADO.NET connection</param> ! void CloseConnection( IDbConnection conn ); /// <summary> *************** *** 57,59 **** } ! } --- 54,56 ---- } ! } \ No newline at end of file Index: DriverConnectionProvider.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Connection/DriverConnectionProvider.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DriverConnectionProvider.cs 1 Sep 2004 03:28:28 -0000 1.3 --- DriverConnectionProvider.cs 31 Dec 2004 16:46:43 -0000 1.4 *************** *** 1,7 **** using System; - using System.Collections; using System.Data; ! ! using NHibernate.Driver; namespace NHibernate.Connection --- 1,5 ---- using System; using System.Data; ! using log4net; namespace NHibernate.Connection *************** *** 12,51 **** public class DriverConnectionProvider : ConnectionProvider { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(DriverConnectionProvider)); ! public DriverConnectionProvider() { } ! ! public override IDbConnection GetConnection() { ! log.Debug("Obtaining IDbConnection from Driver"); ! try { IDbConnection conn = Driver.CreateConnection(); ! conn.ConnectionString = ConnectionString; conn.Open(); return conn; ! } ! catch (Exception e) { ! throw new ADOException("Could not create connection from Driver", e); } } ! public override bool IsStatementCache { get { return false; } } public override void Close() { ! log.Info("cleaning up connection pool"); } ! public override void CloseConnection(IDbConnection conn) { ! base.CloseConnection(conn); //TODO: make sure I want to do this - pretty sure I do because of Oracle problems. conn.Dispose(); --- 10,59 ---- public class DriverConnectionProvider : ConnectionProvider { ! private static readonly ILog log = LogManager.GetLogger( typeof( DriverConnectionProvider ) ); ! ! /// <summary></summary> public DriverConnectionProvider() { } ! /// <summary> ! /// ! /// </summary> ! /// <returns></returns> ! public override IDbConnection GetConnection() { ! log.Debug( "Obtaining IDbConnection from Driver" ); ! try { IDbConnection conn = Driver.CreateConnection(); ! conn.ConnectionString = ConnectionString; conn.Open(); return conn; ! } ! catch( Exception e ) { ! throw new ADOException( "Could not create connection from Driver", e ); } } ! /// <summary></summary> ! public override bool IsStatementCache { get { return false; } } + /// <summary></summary> public override void Close() { ! log.Info( "cleaning up connection pool" ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="conn"></param> ! public override void CloseConnection( IDbConnection conn ) { ! base.CloseConnection( conn ); //TODO: make sure I want to do this - pretty sure I do because of Oracle problems. conn.Dispose(); *************** *** 53,57 **** - } ! } --- 61,64 ---- } ! } \ No newline at end of file Index: ConnectionProvider.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Connection/ConnectionProvider.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ConnectionProvider.cs 21 Nov 2004 22:56:28 -0000 1.8 --- ConnectionProvider.cs 31 Dec 2004 16:46:43 -0000 1.9 *************** *** 2,8 **** using System.Collections; using System.Data; ! using NHibernate.Driver; ! using NHibernate.Util; namespace NHibernate.Connection --- 2,8 ---- using System.Collections; using System.Data; ! using log4net; using NHibernate.Driver; ! using Environment = NHibernate.Cfg.Environment; namespace NHibernate.Connection *************** *** 13,33 **** public abstract class ConnectionProvider : IConnectionProvider, IDisposable { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(ConnectionProvider)); private string connString = null; private IDriver driver = null; ! public virtual void CloseConnection(IDbConnection conn) { ! log.Debug("Closing connection"); ! try { conn.Close(); ! } ! catch(Exception e) { ! throw new ADOException("Could not close " + conn.GetType().ToString() + " connection", e); } } ! /// <summary> /// Configures the ConnectionProvider with the Driver and the ConnectionString. --- 13,37 ---- public abstract class ConnectionProvider : IConnectionProvider, IDisposable { ! private static readonly ILog log = LogManager.GetLogger( typeof( ConnectionProvider ) ); private string connString = null; private IDriver driver = null; ! /// <summary> ! /// ! /// </summary> ! /// <param name="conn"></param> ! public virtual void CloseConnection( IDbConnection conn ) { ! log.Debug( "Closing connection" ); ! try { conn.Close(); ! } ! catch( Exception e ) { ! throw new ADOException( "Could not close " + conn.GetType().ToString() + " connection", e ); } } ! /// <summary> /// Configures the ConnectionProvider with the Driver and the ConnectionString. *************** *** 35,50 **** /// <param name="settings">A name/value Dictionary that contains the settings for this ConnectionProvider.</param> /// <exception cref="HibernateException">Thrown when a ConnectionString could not be found or the Driver Class could not be loaded.</exception> ! public virtual void Configure(IDictionary settings) { log.Info( "Configuring ConnectionProvider" ); ! ! connString = settings[ Cfg.Environment.ConnectionString ] as string; ! if (connString==null) { ! throw new HibernateException("Could not find connection string setting"); } ! ! ConfigureDriver(settings); ! } --- 39,54 ---- /// <param name="settings">A name/value Dictionary that contains the settings for this ConnectionProvider.</param> /// <exception cref="HibernateException">Thrown when a ConnectionString could not be found or the Driver Class could not be loaded.</exception> ! public virtual void Configure( IDictionary settings ) { log.Info( "Configuring ConnectionProvider" ); ! ! connString = settings[ Environment.ConnectionString ] as string; ! if( connString == null ) { ! throw new HibernateException( "Could not find connection string setting" ); } ! ! ConfigureDriver( settings ); ! } *************** *** 53,72 **** /// </summary> /// <param name="settings">A name/value Dictionary that contains the settings for the Driver.</param> ! protected virtual void ConfigureDriver(IDictionary settings) { ! string driverClass = settings[ Cfg.Environment.ConnectionDriver] as string; ! if(driverClass==null) { ! throw new HibernateException("The " + Cfg.Environment.ConnectionDriver + " must be specified in the NHibernate configuration section."); } ! else { ! try { ! driver = (IDriver) Activator.CreateInstance(System.Type.GetType(driverClass)); } ! catch (Exception e) { ! throw new HibernateException("Could not create the driver from " + driverClass + ".", e); } --- 57,76 ---- /// </summary> /// <param name="settings">A name/value Dictionary that contains the settings for the Driver.</param> ! protected virtual void ConfigureDriver( IDictionary settings ) { ! string driverClass = settings[ Environment.ConnectionDriver ] as string; ! if( driverClass == null ) { ! throw new HibernateException( "The " + Environment.ConnectionDriver + " must be specified in the NHibernate configuration section." ); } ! else { ! try { ! driver = ( IDriver ) Activator.CreateInstance( System.Type.GetType( driverClass ) ); } ! catch( Exception e ) { ! throw new HibernateException( "Could not create the driver from " + driverClass + ".", e ); } *************** *** 74,85 **** } ! protected virtual string ConnectionString { ! get { return connString;} } ! public IDriver Driver { ! get {return driver;} } --- 78,95 ---- } ! /// <summary> ! /// ! /// </summary> ! protected virtual string ConnectionString { ! get { return connString; } } ! /// <summary> ! /// ! /// </summary> ! public IDriver Driver { ! get { return driver; } } *************** *** 88,99 **** /// </summary> /// <returns></returns> ! public abstract IDbConnection GetConnection(); ! public abstract bool IsStatementCache {get;} public abstract void Close(); #region IDisposable Members public void Dispose() { --- 98,118 ---- /// </summary> /// <returns></returns> ! public abstract IDbConnection GetConnection(); ! /// <summary> ! /// ! /// </summary> ! public abstract bool IsStatementCache { get; } + /// <summary> + /// + /// </summary> public abstract void Close(); #region IDisposable Members + /// <summary> + /// + /// </summary> public void Dispose() { *************** *** 103,105 **** #endregion } ! } --- 122,124 ---- #endregion } ! } \ No newline at end of file Index: UserSuppliedConnectionProvider.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Connection/UserSuppliedConnectionProvider.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** UserSuppliedConnectionProvider.cs 18 Jun 2004 13:59:05 -0000 1.5 --- UserSuppliedConnectionProvider.cs 31 Dec 2004 16:46:43 -0000 1.6 *************** *** 1,9 **** using System; - using System.Data; using System.Collections; ! using NHibernate.Driver; ! ! namespace NHibernate.Connection { /// <summary> --- 1,8 ---- using System; using System.Collections; + using System.Data; + using log4net; ! namespace NHibernate.Connection { /// <summary> *************** *** 14,29 **** /// This implementation indicates that the user is expected to supply an ADO.NET connection /// </remarks> ! public class UserSuppliedConnectionProvider : ConnectionProvider { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(UserSuppliedConnectionProvider)); ! ! public override void CloseConnection(IDbConnection conn) { ! throw new InvalidOperationException("The User is responsible for closing ADO.NET connection - not NHibernate."); } ! public override IDbConnection GetConnection() { ! throw new InvalidOperationException("The user must provide an ADO.NET connection - NHibernate is not creating it."); } --- 13,36 ---- /// This implementation indicates that the user is expected to supply an ADO.NET connection /// </remarks> ! public class UserSuppliedConnectionProvider : ConnectionProvider { ! private static readonly ILog log = LogManager.GetLogger( typeof( UserSuppliedConnectionProvider ) ); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="conn"></param> ! public override void CloseConnection( IDbConnection conn ) { ! throw new InvalidOperationException( "The User is responsible for closing ADO.NET connection - not NHibernate." ); } ! /// <summary> ! /// ! /// </summary> ! /// <returns></returns> ! public override IDbConnection GetConnection() { ! throw new InvalidOperationException( "The user must provide an ADO.NET connection - NHibernate is not creating it." ); } *************** *** 36,51 **** /// NHibernate to use a Connection supplied by the User. /// </remarks> ! public override void Configure(IDictionary settings) { ! log.Warn("No connection properties specified - the user must supply an ADO.NET connection"); ! ! ConfigureDriver(settings); } ! public override bool IsStatementCache { get { return false; } } public override void Close() { --- 43,60 ---- /// NHibernate to use a Connection supplied by the User. /// </remarks> ! public override void Configure( IDictionary settings ) { ! log.Warn( "No connection properties specified - the user must supply an ADO.NET connection" ); ! ! ConfigureDriver( settings ); } ! /// <summary></summary> ! public override bool IsStatementCache { get { return false; } } + /// <summary></summary> public override void Close() { *************** *** 56,58 **** } ! } --- 65,67 ---- } ! } \ No newline at end of file Index: ConnectionProviderFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Connection/ConnectionProviderFactory.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ConnectionProviderFactory.cs 22 Nov 2004 03:52:17 -0000 1.7 --- ConnectionProviderFactory.cs 31 Dec 2004 16:46:43 -0000 1.8 *************** *** 1,49 **** using System; using System.Collections; ! using System.Configuration; ! using System.Data; ! ! using NHibernate.Cfg; ! namespace NHibernate.Connection { /// <summary> /// Instanciates a connection provider given configuration properties. /// </summary> ! public sealed class ConnectionProviderFactory { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(ConnectionProviderFactory)); ! // cannot be instantiated ! private ConnectionProviderFactory() { ! throw new InvalidOperationException("ConnectionProviderFactory can not be instantiated."); } ! public static IConnectionProvider NewConnectionProvider(IDictionary settings) { IConnectionProvider connections = null; ! string providerClass = settings[Cfg.Environment.ConnectionProvider] as string; ! if (providerClass != null) { ! try { ! log.Info("Intitializing connection provider: " + providerClass); ! connections = (IConnectionProvider) Activator.CreateInstance(System.Type.GetType(providerClass)); ! } ! catch (Exception e) { ! log.Fatal("Could not instantiate connection provider", e); ! throw new HibernateException("Could not instantiate connection provider: " + providerClass); } ! } ! else { connections = new UserSuppliedConnectionProvider(); } ! connections.Configure(settings); return connections; } } ! } --- 1,52 ---- using System; using System.Collections; ! using log4net; ! using Environment = NHibernate.Cfg.Environment; ! namespace NHibernate.Connection { /// <summary> /// Instanciates a connection provider given configuration properties. /// </summary> ! public sealed class ConnectionProviderFactory { ! private static readonly ILog log = LogManager.GetLogger( typeof( ConnectionProviderFactory ) ); ! // cannot be instantiated ! private ConnectionProviderFactory() { ! throw new InvalidOperationException( "ConnectionProviderFactory can not be instantiated." ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="settings"></param> ! /// <returns></returns> ! public static IConnectionProvider NewConnectionProvider( IDictionary settings ) { IConnectionProvider connections = null; ! string providerClass = settings[ Environment.ConnectionProvider ] as string; ! if( providerClass != null ) { ! try { ! log.Info( "Intitializing connection provider: " + providerClass ); ! connections = ( IConnectionProvider ) Activator.CreateInstance( System.Type.GetType( providerClass ) ); ! } ! catch( Exception e ) { ! log.Fatal( "Could not instantiate connection provider", e ); ! throw new HibernateException( "Could not instantiate connection provider: " + providerClass ); } ! } ! else { connections = new UserSuppliedConnectionProvider(); } ! connections.Configure( settings ); return connections; } } ! } \ No newline at end of file |