Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data.NHibernate/Data/NHibernate
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv10526
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.NHibernate/Data/NHibernate/LocalSessionFactoryObject.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** LocalSessionFactoryObject.cs 8 Aug 2007 17:47:37 -0000 1.3
--- LocalSessionFactoryObject.cs 29 Jan 2008 19:48:45 -0000 1.4
***************
*** 35,39 ****
{
/// <summary>
! /// An IFactoryObject that creates a local Hibernate SessionFactory instance.
/// Behaves like a SessionFactory instance when used as bean reference,
/// e.g. for HibernateTemplate's "SessionFactory" property.
--- 35,39 ----
{
/// <summary>
! /// An IFactoryObject that creates a local Hibernate SessionFactory instance.
/// Behaves like a SessionFactory instance when used as bean reference,
/// e.g. for HibernateTemplate's "SessionFactory" property.
***************
*** 62,65 ****
--- 62,67 ----
private string[] mappingResources;
+ private string[] configFilenames;
+
/// <summary>
/// TODO: consider changing to NamevalueCollection for easier
***************
*** 105,108 ****
--- 107,118 ----
/// <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.
***************
*** 220,227 ****
if (this.dbProvider != null)
{
! config.SetProperty(Environment.ConnectionString,
! dbProvider.ConnectionString);
! //TODO infer ConnectionDriver and ConnectionProvider from
! //dbProvider?
}
--- 230,235 ----
if (this.dbProvider != null)
{
! config.SetProperty(Environment.ConnectionString, dbProvider.ConnectionString);
!
}
***************
*** 248,251 ****
--- 256,267 ----
}
+ if (configFilenames != null)
+ {
+ foreach (string configFilename in configFilenames)
+ {
+ config.Configure(configFilename);
+ }
+ }
+
// Perform custom post-processing in subclasses.
PostProcessConfiguration(config);
***************
*** 264,269 ****
public void Dispose()
{
! log.Info("Closing Hibernate SessionFactory");
! sessionFactory.Close();
}
--- 280,293 ----
public void Dispose()
{
! if (sessionFactory != null)
! {
! #region Instrumentation
! if (log.IsInfoEnabled)
! {
! log.Info("Closing Hibernate SessionFactory");
! }
! #endregion
! sessionFactory.Close();
! }
}
***************
*** 310,313 ****
--- 334,338 ----
return config.BuildSessionFactory();
}
+
}
}
|