/**
   * Get a locker for this database handle for a read or cursor operation.
   *
   * @throws IllegalArgumentException via db/cursor read/write methods.
   */
  public static Locker getReadableLocker(
      Environment env, Database dbHandle, Locker locker, boolean readCommittedIsolation)
      throws DatabaseException {

    DatabaseImpl dbImpl = DbInternal.getDatabaseImpl(dbHandle);
    if (!dbImpl.isTransactional() && locker != null && locker.isTransactional()) {
      throw new IllegalArgumentException(
          "A Transaction cannot be used because the" + " database was opened non-transactionally");
    }

    /* Don't reuse a non-transactional locker. */
    if (locker != null && !locker.isTransactional()) {
      locker = null;
    }

    /*
     * Request read-comitted if that isolation level is configured for the
     * locker being reused, or if true is passed for the parameter (this is
     * the case when read-committed is configured for the cursor).
     */
    if (locker != null && locker.isReadCommittedIsolation()) {
      readCommittedIsolation = true;
    }

    return getReadableLocker(env, locker, readCommittedIsolation);
  }
Ejemplo n.º 2
0
 public static Locker getReadableLocker__wrappee__base(
     Environment env,
     Database dbHandle,
     Locker locker,
     boolean retainNonTxnLocks,
     boolean readCommittedIsolation)
     throws DatabaseException {
   DatabaseImpl dbImpl = DbInternal.dbGetDatabaseImpl(dbHandle);
   if (!dbImpl.isTransactional() && locker != null && locker.isTransactional()) {
     throw new DatabaseException(
         "A Transaction cannot be used because the"
             + " database was opened"
             + " non-transactionally");
   }
   if (locker != null && !locker.isTransactional() && !retainNonTxnLocks) {
     locker = null;
   }
   if (locker != null && locker.isReadCommittedIsolation()) {
     readCommittedIsolation = true;
   }
   return getReadableLocker(env, locker, retainNonTxnLocks, readCommittedIsolation);
 }