Example usage for java.util.concurrent.locks ReentrantLock unlock

List of usage examples for java.util.concurrent.locks ReentrantLock unlock

Introduction

In this page you can find the example usage for java.util.concurrent.locks ReentrantLock unlock.

Prototype

public void unlock() 

Source Link

Document

Attempts to release this lock.

Usage

From source file:org.apache.openejb.resource.jdbc.dbcp.BasicDataSource.java

public String getJdbcUrl() {
    final ReentrantLock l = lock;
    l.lock();/*from  ww  w . ja  va2s.c  o m*/
    try {
        return super.getUrl();
    } finally {
        l.unlock();
    }
}

From source file:org.apache.openejb.resource.jdbc.dbcp.BasicDataSource.java

public void setUserName(final String string) {
    final ReentrantLock l = lock;
    l.lock();/*from  w  w  w . j a v  a 2s.c o m*/
    try {
        super.setUsername(string);
    } finally {
        l.unlock();
    }
}

From source file:org.ut.biolab.medsavant.server.db.LockController.java

/**
 * Release the lock. If force is false, only the thread which requested the
 * lock may unlock. However, in the case where that thread no longer exists,
 * it is necessary to force the unlock./*from w  ww . ja v a 2s. c o  m*/
 *
 * @param database The database containing the project to unlock.
 * @param projectID The project ID to unlock.
 * @param force Whether to force the unlock.
 * @throws org.ut.biolab.medsavant.shared.model.LockException
 */
public synchronized void releaseLock(String database, int projectID, boolean force) throws LockException {

    LOG.info("Server unlock requested");

    Key k = new Key(database, projectID);
    ReentrantLock lock = locks.get(k);

    // no lock exists for this project
    if (lock == null) {
        throw new LockException("No lock exists");
    }

    if (force) {
        while (lock.isLocked()) {
            lock.unlock();
        }
        LOG.info(String.format("Server forcibly unlocked - hold count %d", lock.getHoldCount()));

        // unlock it, or decrement the hold count
    } else if (lock.isHeldByCurrentThread()) {
        lock.unlock();
        LOG.info(String.format("Server unlocked - hold count %d", lock.getHoldCount()));
        // not allowed to lock
    } else {
        throw new LockException("Database could not be unlocked");
    }
}

From source file:org.apache.openejb.resource.jdbc.dbcp.BasicDataSource.java

public String getUserName() {
    final ReentrantLock l = lock;
    l.lock();/*from w w w.ja  va  2 s .  c  o  m*/
    try {
        return super.getUsername();
    } finally {
        l.unlock();
    }
}

From source file:org.apache.openejb.resource.jdbc.dbcp.BasicDataSource.java

/**
 * Returns the password codec class name to use to retrieve plain text
 * password.//from  ww w.  ja va 2  s .  c  o m
 *
 * @return the password codec class
 */
public String getPasswordCipher() {
    final ReentrantLock l = lock;
    l.lock();
    try {
        return this.passwordCipher;
    } finally {
        l.unlock();
    }
}

From source file:org.apache.openejb.resource.jdbc.dbcp.BasicDataSource.java

public void setJdbcDriver(final String string) {
    final ReentrantLock l = lock;
    l.lock();// ww w . java2s  . c  om
    try {
        super.setDriverClassName(string);
    } finally {
        l.unlock();
    }
}

From source file:org.apache.openejb.resource.jdbc.dbcp.BasicDataSource.java

public void setMaxWait(final int maxWait) {
    final ReentrantLock l = lock;
    l.lock();/* w ww  . j  a v  a2 s.c  om*/
    try {
        super.setMaxWait((long) maxWait);
    } finally {
        l.unlock();
    }
}

From source file:org.apache.openejb.resource.jdbc.dbcp.BasicDataSource.java

public String getJdbcDriver() {
    final ReentrantLock l = lock;
    l.lock();//from  ww w.  j  av a2s .  c o  m
    try {
        return super.getDriverClassName();
    } finally {
        l.unlock();
    }
}

From source file:org.apache.openejb.resource.jdbc.dbcp.BasicDataSource.java

/**
 * <p>//from w w w  .j  ava 2s . c o  m
 * Sets the {@link #passwordCipher}.
 * </p>
 *
 * @param passwordCipher password codec value
 */
public void setPasswordCipher(final String passwordCipher) {
    final ReentrantLock l = lock;
    l.lock();
    try {
        this.passwordCipher = passwordCipher;
    } finally {
        l.unlock();
    }
}

From source file:org.commoncrawl.service.parser.client.Dispatcher.java

public void nodeOffline(ParserNode theNode) {
    final ReentrantLock lock = this.lock;
    lock.lock();/*from  ww  w.j a  v a2  s .  c o  m*/
    try {
        _onlineNodes.remove(theNode);
    } finally {
        lock.unlock();
    }
}