Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data.NHibernate12/Data/NHibernate
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv10515
Modified Files:
LocalSessionFactoryObject.cs
Log Message:
SPRNET-841 - Add option to specify external hibernate configuration files (hibernate.cfg.xml) in LocalSessionFactoryObject
Index: LocalSessionFactoryObject.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data.NHibernate12/Data/NHibernate/LocalSessionFactoryObject.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** LocalSessionFactoryObject.cs 30 Oct 2007 15:29:10 -0000 1.8
--- LocalSessionFactoryObject.cs 29 Jan 2008 19:48:40 -0000 1.9
***************
*** 62,65 ****
--- 62,67 ----
private string[] mappingResources;
+ private string[] configFilenames;
+
/// <summary>
/// TODO: consider changing to NamevalueCollection for easier
***************
*** 89,94 ****
/// <summary>
/// Initializes a new instance of the <see cref="LocalSessionFactoryObject"/> class.
! /// </summary>
! public LocalSessionFactoryObject()
{
--- 91,96 ----
/// <summary>
/// Initializes a new instance of the <see cref="LocalSessionFactoryObject"/> class.
! /// </summary>
! public LocalSessionFactoryObject()
{
***************
*** 109,112 ****
--- 111,122 ----
/// <summary>
+ /// Sets the hibernate configuration files to load, i.e. hibernate.cfg.xml.
+ /// </summary>
+ public string[] ConfigFilenames
+ {
+ set { configFilenames = value; }
+ }
+
+ /// <summary>
/// Sets the locations of Spring IResources that contain mapping
/// files.
***************
*** 238,243 ****
config.SetProperty(Environment.ConnectionString,
dbProvider.ConnectionString);
- //TODO infer ConnectionDriver and ConnectionProvider from
- //dbProvider?
}
--- 248,251 ----
***************
*** 273,276 ****
--- 281,292 ----
}
+ if (configFilenames != null)
+ {
+ foreach (string configFilename in configFilenames)
+ {
+ config.Configure(configFilename);
+ }
+ }
+
// Perform custom post-processing in subclasses.
PostProcessConfiguration(config);
***************
*** 289,294 ****
public void Dispose()
{
! log.Info("Closing Hibernate SessionFactory");
! sessionFactory.Close();
}
--- 305,319 ----
public void Dispose()
{
! if (sessionFactory != null)
! {
! #region Instrumentation
! if (log.IsInfoEnabled)
! {
! log.Info("Closing Hibernate SessionFactory");
! }
! #endregion
! sessionFactory.Close();
! }
!
}
***************
*** 337,340 ****
--- 362,366 ----
return config.BuildSessionFactory();
}
+
}
}
|