Small change request

Feb 22, 2008 at 9:34 AM
Edited Feb 22, 2008 at 9:36 AM
// This message is addressed to the product developer //

Hi,

I find this job extreemly useful for everybody. However, I have faced an integration problelms. It is difficult to integrate it with other technologies based on NH due to configuration. It's easy to drop these constraints allowing the user to provide own session factory object. I have prepared an HTTP module implementation that allows such modification:

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using NHibernateProvider.Helper;

namespace NHibernateProvider
{
public class NHibernateProviderModule : IHttpModule
{
#region IHttpModule Members

public void Dispose()
{
// ...
}

public void Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(OnBeginRequest);
}

protected virtual void OnBeginRequest(object sender, EventArgs e)
{
NHibernateHelper.Initialize();
}

#endregion
}
}

This module requires to provide following methods in the NHibernateHelper class _instead_ of the static constructor:

public static void Initialize()
{
sessionFactory = new Configuration().Configure().BuildSessionFactory();
}
public static void Initialize(ISessionFactory extSessionFactory)
{
sessionFactory = extSessionFactory;
}

and to drop readonly constraint on the sessionFactory member.

These modification allow the user to derive from the module and overload OnBeginRequest method where custom session factory can be injected. Actualy I would like to use this mechanism for integration with Spring.Net. So, the question is whether it is possible to put it to the base code of NHibernateProvider.
Coordinator
Mar 4, 2008 at 12:37 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.