I have blogged a couple of months ago about Windsor-managed httpmodules: http://bugsquash.blogspot.com/2009/11/windsor-managed-httpmodules.html
This way you could have the UnitOfWorkModule get ISessionFactory injected normally, which would make testing easier. On Jan 15, 4:29 pm, Jason Meckley <[email protected]> wrote: > just the unit of work module. > > On Jan 15, 1:04 pm, Mauricio Scheffer <[email protected]> > wrote: > > > > > I'm not sure I understand: do you want to test the whole session-per- > > request flow (with controllers and everything) or just the > > UnitOfWorkModule ? > > > On Jan 15, 1:46 pm, Jason Meckley <[email protected]> wrote: > > > > I use NH with MR and the Session Per View Model. currently I use an > > > HttpMoudule. to manage session scope like this: > > > public class UnitOfWorkModule : IHttpModule > > > { > > > public void Init(HttpApplication context) > > > { > > > var factory = WindsorContainerAccessorUtil > > > .ObtainContainer() > > > .Resolve<ISessionFactory>(); > > > context.BeginRequest += (sender, e) => > > > CurrentSessionContext.Bind > > > (factory.OpenSession()); > > > context.EndRequest += (sender, e) => > > > CurrentSessionContext.Unbind > > > (factory).Dispose(); > > > } > > > > public void Dispose() > > > { > > > }} > > > > which works, but I cannot test this and requires me to configure the > > > web.config file. I could put this in the global file, but I still > > > cannot test that. > > > > I tried implementing an IMonoRailExtension to hook into the > > > ExtensionManager Pre/Post ControllerProcessing but that failed on 2 > > > accounts. > > > 1. a default ctor is required, so it's not resolved from Windsor and I > > > cannot inject the sessionfactory as a ctor dependency. > > > > 2. If I use WindsorContainerAccessorUtil to resolve the sessionfactory > > > from the container. i get a "Session not bound to the current > > > context". reviewing the source i found the controller is resolved > > > before calling pre/post controller processing. so this is out as well. > > > > Is there an extension point in MR 1.0.3.0 where I can easily test NH > > > session scope management? the scope would look like this > > > > 1. request is received > > > 2. MR begins processing > > > 3. open session > > > 4. resolve controller > > > 5. process action > > > 6. dispose of session > > > 7. MR completes processing > > > 8. response is sent
-- You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.
