public static void SetRootContainer(IContainer container) { _defaultContainer = container; // For the command processor, logical call context ends up flowing // to other threads. CallContext stays scoped to the executing task. _unitOfWorkStorage = new UnitOfWorkStorage <UnitOfWorkContainer>(useLogicalCallContext: false); }
public void Shutdown(IUnitOfWorkStorage storage) { if (log.IsInfoEnabled) log.Info(Consts.ENTERED); if( null == storage ) throw new ArgumentNullException("storage", "Cannot clear TransactionManager without access to UoW storage"); ITransactionManager transMan = storage.RetrieveTransactionManager(); if( null != transMan ) { if( transMan.IsInTransaction ) { if (log.IsErrorEnabled) log.Error("Shutting down with an open transaction! The transaction is being rolled back"); transMan.Rollback(); } if (log.IsDebugEnabled) log.Debug("Clearing transaction manager..."); storage.ClearTransactionManager(); } if (NHibernateSession != null && NHibernateSession.IsOpen) { if (log.IsDebugEnabled) log.Debug("Closing session..."); NHibernateSession.Close(); if (log.IsDebugEnabled) log.Debug("Disposing session..."); NHibernateSession.Dispose(); if (log.IsDebugEnabled) log.Debug("Done"); } }
protected override void Context() { base.Context(); _repositoryFactory = new StructureMapRepositoryFactory(); _uowStorage = new ThreadStaticUnitOfWorkStorage(); }
/// <summary> /// Used for TESTING purposes only. /// Tells the resolver to use the provided container for the current scope. /// This will allow a greater nested container depth since we have tests /// that do setup with multiple containers. /// </summary> public static IDisposable PushTestContainer(IContainer container) { // In a test context, use LogicalCallContext if (_unitOfWorkStorage == null) { _unitOfWorkStorage = new UnitOfWorkStorage <UnitOfWorkContainer>(useLogicalCallContext: true); } return(SetUnitOfWorkContainer(container)); }
public NHibernateConfig(IRepositoryFactory repositoryFactory, IUnitOfWorkStorage storage) : base(new NHibernateUoWFactory(), repositoryFactory, storage) { if (log.IsInfoEnabled) log.Info(Consts.ENTERED); _config = new Configuration(); _config.Configure(); ConfigureUnitOfWork(); }
protected override void SharedContext() { mockUoW = new MockUnitOfWork(); mockUoWFactory = new MockUoWFactory(mockUoW); IRepositoryFactory repositoryFactory = new StructureMapRepositoryFactory(); uowStorage = new ThreadStaticUnitOfWorkStorage(); UnitOfWork.Configure(new UnitOfWorkConfigurationBase(mockUoWFactory, repositoryFactory, uowStorage)); }
public UnitOfWorkConfigurationBase(IUnitOfWorkFactory uowFactory, IRepositoryFactory repositoryFactory, IUnitOfWorkStorage storage) { if (log.IsInfoEnabled) log.Info(Consts.ENTERED); if (log.IsDebugEnabled) log.Debug(new object[] { uowFactory, repositoryFactory, storage } ); UnitOfWorkFactory = uowFactory; RepositoryFactory = repositoryFactory; UnitOfWorkStorage = storage; if (log.IsDebugEnabled) log.Debug("Done creating UoWConfiguration"); }
public NHibernateConfig(IRepositoryFactory repositoryFactory, IUnitOfWorkStorage storage) : base(new NHibernateUoWFactory(), repositoryFactory, storage) { if (log.IsInfoEnabled) { log.Info(Consts.ENTERED); } _config = new Configuration(); _config.Configure(); ConfigureUnitOfWork(); }
public void Shutdown(IUnitOfWorkStorage storage) { if (log.IsInfoEnabled) { log.Info(Consts.ENTERED); } if (null == storage) { throw new ArgumentNullException("storage", "Cannot clear TransactionManager without access to UoW storage"); } ITransactionManager transMan = storage.RetrieveTransactionManager(); if (null != transMan) { if (transMan.IsInTransaction) { if (log.IsErrorEnabled) { log.Error("Shutting down with an open transaction! The transaction is being rolled back"); } transMan.Rollback(); } if (log.IsDebugEnabled) { log.Debug("Clearing transaction manager..."); } storage.ClearTransactionManager(); } if (NHibernateSession != null && NHibernateSession.IsOpen) { if (log.IsDebugEnabled) { log.Debug("Closing session..."); } NHibernateSession.Close(); if (log.IsDebugEnabled) { log.Debug("Disposing session..."); } NHibernateSession.Dispose(); if (log.IsDebugEnabled) { log.Debug("Done"); } } }
public NHibernateConfig(IDictionary<string, string> properties, IRepositoryFactory repositoryFactory, IUnitOfWorkStorage storage, params Assembly[] assemblies) : base(new NHibernateUoWFactory(), repositoryFactory, storage) { _config = new Configuration { Properties = properties }; if (assemblies != null) { foreach (Assembly assembly in assemblies) { _config = _config.AddAssembly(assembly); } } ConfigureUnitOfWork(); }
public NHibernateConfig(Stream configData, IRepositoryFactory repositoryFactory, IUnitOfWorkStorage storage) : base(new NHibernateUoWFactory(), repositoryFactory, storage) { if (log.IsInfoEnabled) log.Info(Consts.ENTERED); if (log.IsDebugEnabled) log.Debug(configData); _config = new Configuration(); XmlTextReader reader = new XmlTextReader(configData); _config.Configure(reader); ConfigureUnitOfWork(); reader.Close(); }
public UnitOfWorkConfigurationBase(IUnitOfWorkFactory uowFactory, IRepositoryFactory repositoryFactory, IUnitOfWorkStorage storage) { if (log.IsInfoEnabled) { log.Info(Consts.ENTERED); } if (log.IsDebugEnabled) { log.Debug(new object[] { uowFactory, repositoryFactory, storage }); } UnitOfWorkFactory = uowFactory; RepositoryFactory = repositoryFactory; UnitOfWorkStorage = storage; if (log.IsDebugEnabled) { log.Debug("Done creating UoWConfiguration"); } }
public NHibernateConfig(Func<Configuration> configurationAction, IRepositoryFactory repositoryFactory, IUnitOfWorkStorage storage) : base(new NHibernateUoWFactory(), repositoryFactory, storage) { _config = configurationAction(); ConfigureUnitOfWork(); }
public NHibernateConfig(IDictionary <string, string> properties, IRepositoryFactory repositoryFactory, IUnitOfWorkStorage storage, params Assembly[] assemblies) : base(new NHibernateUoWFactory(), repositoryFactory, storage) { _config = new Configuration { Properties = properties }; if (assemblies != null) { foreach (Assembly assembly in assemblies) { _config = _config.AddAssembly(assembly); } } ConfigureUnitOfWork(); }
public NHibernateConfig(Stream configData, IRepositoryFactory repositoryFactory, IUnitOfWorkStorage storage) : base(new NHibernateUoWFactory(), repositoryFactory, storage) { if (log.IsInfoEnabled) { log.Info(Consts.ENTERED); } if (log.IsDebugEnabled) { log.Debug(configData); } _config = new Configuration(); XmlTextReader reader = new XmlTextReader(configData); _config.Configure(reader); ConfigureUnitOfWork(); reader.Close(); }
public NHibernateConfig(Func <Configuration> configurationAction, IRepositoryFactory repositoryFactory, IUnitOfWorkStorage storage) : base(new NHibernateUoWFactory(), repositoryFactory, storage) { _config = configurationAction(); ConfigureUnitOfWork(); }
public void Shutdown(IUnitOfWorkStorage storage) { WasStopped = true; }
/// <summary> /// Initialiser method /// </summary> /// <param name="factory">The NHibernate session factory</param> /// <param name="storage">The storage mechanism to use</param> public static void Initialise(ISessionFactory factory, IUnitOfWorkStorage storage) { m_sessionFactory = factory; Storage = storage; }
/// <summary> /// Initialiser method /// </summary> /// <param name="config">The fluent NHibernate configuration from which to build a session factory</param> /// <param name="storage">The storage mechanism to use</param> public static void Initialise(FluentConfiguration config, IUnitOfWorkStorage storage) { Initialise(config.BuildSessionFactory(), storage); }