2012-01-05 11 views
0

私はセッションごとにリクエストパターンを実行します。 ISessionFactoryを管理するための iは、スレッドセーフsingletoneを使用します。asp.net Nhibernateセッション管理

public class SessionManager 
    { 
     private static readonly ILog Log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 
     private readonly ISessionFactory sessionFactory; 
     public static ISessionFactory SessionFactory 
     { 
      get { return Instance.sessionFactory; } 
     } 
     private ISessionFactory GetSessionFactory() 
     { 
      return sessionFactory; 
     } 
     public static ISession OpenSession() 
     { 
      return Instance.GetSessionFactory().OpenSession(); 
     } 
     public static ISession CurrentSession 
     { 
      get 
      { 
       if (!CurrentSessionContext.HasBind(Instance.GetSessionFactory())) 
        return null; 
       return Instance.GetSessionFactory().GetCurrentSession(); 
      } 
     } 


     public static SessionManager Instance 
     { 
      get 
      { 
       return NestedSessionManager.sessionManager; 
      } 
     } 
     private SessionManager() 
     { 
      Log.Info("Start creating factory"); 
      Configuration configuration = new Configuration().Configure(); 
      sessionFactory = configuration.BuildSessionFactory(); 
      Log.Info("End creating factory"); 

     } 

     class NestedSessionManager 
     { 
      internal static readonly SessionManager sessionManager = 
       new SessionManager(); 
     } 
    } 

私は、すべてのユーザーの要求に対して一度ファクトリを作成理解し、私は私の工場はすべての15-45分を再作成し、私のログを見ての通り。それは時間がかかるので、アプリケーションの読み込みが遅くなります。

私の考えは間違っていますか?

答えて

3

アプリケーションを再起動できることがいくつかあります。 theseのいずれかが起こっていませんか?