1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.Applications
.MindDump
.Web
25 public class MindDumpHttpApplication
: HttpApplication
, IContainerAccessor
27 private static readonly String DefaultSessionFactory
= "nhibernate.sessfactory.default";
29 private static WindsorContainer container
;
31 public MindDumpHttpApplication()
33 // this.BeginRequest += new EventHandler(OnBeginRequest);
34 // this.EndRequest += new EventHandler(OnEndRequest);
37 // public void OnBeginRequest(object sender, EventArgs e)
39 // ISessionFactory sessFac = (ISessionFactory) container[ typeof(ISessionFactory) ];
41 // ISession session = sessFac.OpenSession();
43 // SessionManager.Push(session, DefaultSessionFactory);
45 // HttpContext.Current.Items.Add( "nh.session", session );
48 // public void OnEndRequest(object sender, EventArgs e)
50 // ISession session = (ISession) HttpContext.Current.Items["nh.session"];
52 // if (session == null) return;
56 // SessionManager.Pop(DefaultSessionFactory);
60 // catch(Exception ex)
62 // HttpContext.Current.Trace.Warn( "Error", "EndRequest: " + ex.Message, ex );
66 public void Application_OnStart()
68 container
= new MindDumpContainer();
71 public void Application_OnEnd()
76 #region IContainerAccessor implementation
78 public IWindsorContainer Container
80 get { return container; }