コード例 #1
0
  /**
   * Retrive a session. There will only exists only ONE open session per application. This means
   * that the closeSession() MUST be called once a getSession() has been called, else the system
   * will be blocked!
   *
   * @return
   */
  private Session getSession(ISession s) {
    // Lock here
    synchronized (sf) {
      while (sessionLocked) {
        try {
          sf.wait();
        } catch (InterruptedException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          throw new ConcurrencyFailureException("Session wait got interrupted", e);
        }
      }

      // Create Session interceptor...
      DaoSessionReaderInterceptor inter = new DaoSessionReaderInterceptor();
      // inter.setDaoReader(this);
      inter.setSession(s);

      Session session = sf.openSession(inter);

      // sessionLocked = true;
      return (session);
    }
  }