From 7fe428a68ec2aa45b752dea0796bb0f3deef44e3 Mon Sep 17 00:00:00 2001 From: markpollack Date: Mon, 14 Dec 2009 23:21:08 +0000 Subject: [PATCH] Sync NH12 with recent changes for NH2x in changeset https://fisheye.springsource.org/changelog/spring-net/?name=lahma&cs=854 --- .../NHibernate/LocalSessionFactoryObject.cs | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/Spring/Spring.Data.NHibernate12/Data/NHibernate/LocalSessionFactoryObject.cs b/src/Spring/Spring.Data.NHibernate12/Data/NHibernate/LocalSessionFactoryObject.cs index 49c82014..4f68daab 100644 --- a/src/Spring/Spring.Data.NHibernate12/Data/NHibernate/LocalSessionFactoryObject.cs +++ b/src/Spring/Spring.Data.NHibernate12/Data/NHibernate/LocalSessionFactoryObject.cs @@ -27,6 +27,7 @@ using Common.Logging; using NHibernate; using NHibernate.Cfg; using NHibernate.Connection; +using Spring.Context; using Spring.Core.IO; using Spring.Dao; using Spring.Dao.Attributes; @@ -61,7 +62,8 @@ namespace Spring.Data.NHibernate /// /// /// Mark Pollack (.NET) - public class LocalSessionFactoryObject : IFactoryObject, IInitializingObject, IPersistenceExceptionTranslator, System.IDisposable + public class LocalSessionFactoryObject : IFactoryObject, IInitializingObject, IPersistenceExceptionTranslator, System.IDisposable, + IApplicationContextAware { #region Fields @@ -87,6 +89,11 @@ namespace Spring.Data.NHibernate private IAdoExceptionTranslator adoExceptionTranslator; + private IResourceLoader resourceLoader; + + private IApplicationContext applicationContext; + + #endregion #region Constants @@ -114,6 +121,32 @@ namespace Spring.Data.NHibernate #region Properties + /// + /// Setting the Application Context determines were resources are loaded from + /// + public IApplicationContext ApplicationContext + { + set { this.applicationContext = value; } + } + + /// + /// Gets or sets the to use for loading mapping assemblies etc. + /// + public IResourceLoader ResourceLoader + { + get + { + if (resourceLoader == null) + { + resourceLoader = new ConfigurableResourceLoader(); + } + return resourceLoader; + } + set { resourceLoader = value; } + } + + + /// /// Sets the assemblies to load that contain mapping files. /// @@ -327,6 +360,12 @@ namespace Spring.Data.NHibernate if (this.mappingResources != null) { + IResourceLoader loader = this.ResourceLoader; + if (loader == null) + { + loader = this.applicationContext; + } + foreach (string resourceName in mappingResources) { config.AddInputStream(resourceLoader.GetResource(resourceName).InputStream);