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);