Spring.Data.NHibernate.SessionFactoryUtils.ProcessDeferredClose C# (CSharp) Method

ProcessDeferredClose() public static method

Process Sessions that have been registered for deferred close for the given SessionFactory.
If there is no session factory associated with the thread.
public static ProcessDeferredClose ( ISessionFactory sessionFactory ) : void
sessionFactory ISessionFactory The session factory.
return void
        public static void ProcessDeferredClose(ISessionFactory sessionFactory) 
        {
            AssertUtils.ArgumentNotNull(sessionFactory, "No SessionFactory specified");

            IDictionary holderDictionary = LogicalThreadContext.GetData(DeferredCloseHolderDataSlotName) as IDictionary;
          
            if (holderDictionary == null || !holderDictionary.Contains(sessionFactory)) 
            {
                throw new InvalidOperationException("Deferred close not active for SessionFactory [" + sessionFactory + "]");
            }
            log.Debug("Processing deferred close of Hibernate Sessions");
            Set sessions = (Set) holderDictionary[sessionFactory];
            holderDictionary.Remove(sessionFactory);
            foreach (ISession session in sessions)
            {
                CloseSession(session);
            }

            if (holderDictionary.Count == 0)
            {
                LogicalThreadContext.FreeNamedDataSlot(DeferredCloseHolderDataSlotName);
            }


        }