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

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

Introduction

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

Prototype

void unlock();

Source Link

Document

Releases the lock.

Usage

From source file:info.pancancer.arch3.worker.WorkflowRunner.java

/**
 * Get the stderr of the running command.
 *
 * @return//from   w ww  .j a v  a2  s .  c  o  m
 */
public String getStdErr() {
    String s;
    Lock lock = new ReentrantLock();
    lock.lock();
    try {
        this.errorStream.flush();
        s = this.errorStream.getAllLinesAsString();
    } finally {
        lock.unlock();
    }
    return s;
}

From source file:info.pancancer.arch3.worker.WorkflowRunner.java

/**
 * Get the stdout of the running command.
 *
 * @return//www .j  av a  2 s. c om
 */
public String getStdOut() {
    String s;
    Lock lock = new ReentrantLock();
    lock.lock();
    try {
        this.outputStream.flush();
        s = this.outputStream.getAllLinesAsString();
    } finally {
        lock.unlock();
    }
    return s;
}

From source file:edu.internet2.middleware.shibboleth.common.relyingparty.provider.SAMLMDRelyingPartyConfigurationManager.java

/** {@inheritDoc} */
public RelyingPartyConfiguration getDefaultRelyingPartyConfiguration() {
    Lock readLock = getReadWriteLock().readLock();
    readLock.lock();//from  w  w w.j a  v a 2s  . com
    try {
        return rpConfigs.get(DEFAULT_RP_NAME);
    } finally {
        readLock.unlock();
    }
}

From source file:edu.internet2.middleware.shibboleth.common.relyingparty.provider.SAMLMDRelyingPartyConfigurationManager.java

/** {@inheritDoc} */
public RelyingPartyConfiguration getAnonymousRelyingConfiguration() {
    Lock readLock = getReadWriteLock().readLock();
    readLock.lock();/*w w  w  .j  a  v a2  s .c  o m*/
    try {
        return rpConfigs.get(ANONYMOUS_RP_NAME);
    } finally {
        readLock.unlock();
    }
}

From source file:org.apache.stratos.common.clustering.impl.HazelcastDistributedObjectProvider.java

/**
 * Releases a given distributed/local lock.
 *
 * @param lock//from w  w w  . j a  v  a 2  s .  c o m
 */
@Override
public void releaseLock(Lock lock) {
    if (isClustered()) {
        releaseDistributedLock((ILock) lock);
    } else {
        lock.unlock();
    }
}

From source file:edu.internet2.middleware.shibboleth.idp.profile.IdPProfileHandlerManager.java

/** {@inheritDoc} */
public ProfileHandler getProfileHandler(ServletRequest request) {
    ProfileHandler handler;//from ww w.j  a  v a 2  s .co m

    String requestPath = ((HttpServletRequest) request).getPathInfo();
    log.debug("{}: Looking up profile handler for request path: {}", getId(), requestPath);

    Lock readLock = getReadWriteLock().readLock();
    readLock.lock();
    try {
        handler = profileHandlers.get(requestPath);
    } finally {
        readLock.unlock();
    }

    if (handler != null) {
        log.debug("{}: Located profile handler of the following type for the request path: {}", getId(),
                handler.getClass().getName());
    } else {
        log.debug("{}: No profile handler registered for request path {}", getId(), requestPath);
    }
    return handler;
}

From source file:org.pentaho.reporting.platform.plugin.cache.FileSystemCacheBackend.java

/**
 * Locks are released in reverse order. First we release the more specialized locks and traverse upwards towards the
 * root directory./*from w  w w . java2s  . co m*/
 *
 * @param locks
 */
private void unlock(final List<Lock> locks) {
    for (int i = locks.size() - 1; i >= 0; i--) {
        final Lock lock = locks.get(i);
        lock.unlock();
    }
}

From source file:net.sf.fakenames.fddemo.BaseDirLayout.java

public void init() throws IOException {
    home = getBaseDir();/* w  ww .j a v  a2 s.co m*/

    mountInfo = MountsSingleton.get(os);

    final HashMap<File, String> pathNameMap = new HashMap<>();

    File systemRoot = Environment.getRootDirectory();
    try {
        systemRoot = systemRoot.getCanonicalFile();
    } catch (IOException ignore) {
        // ok
    }
    pathNameMap.put(systemRoot, "Android system root");

    File filesDir = getFilesDir();
    try {
        filesDir = filesDir.getCanonicalFile();
    } catch (IOException ignore) {
        // ok
    }
    pathNameMap.put(filesDir, "Internal private storage");

    File[] external = ContextCompat.getExternalFilesDirs(this, null);
    for (int i = 0; i < external.length; ++i) {
        File resolved = external[i];

        if (resolved == null)
            continue;

        try {
            resolved = resolved.getCanonicalFile();
        } catch (IOException ignore) {
            // ok
        }
        pathNameMap.put(resolved, "External storage " + i);
    }

    List<StorageVolume> volumes = new ArrayList<>();
    if (Build.VERSION.SDK_INT >= 24) {
        final StorageManager sm = (StorageManager) getSystemService(STORAGE_SERVICE);
        volumes.addAll(sm.getStorageVolumes());
    }

    final Lock lock = mountInfo.getLock();
    lock.lock();
    try {
        parseMounts(pathNameMap, volumes);
    } finally {
        lock.unlock();
    }

}

From source file:org.mule.security.oauth.DefaultRefreshTokenManager.java

/**
 * {@inheritDoc} This implementation uses a lock to guarantee that no refresh
 * token is consumed more than once/*from   w  w  w.  j  ava  2 s  .  com*/
 *
 * @see org.mule.security.oauth.RefreshTokenManager#refreshToken(org.mule.security.oauth.OAuth2Adapter,
 * java.lang.String)
 */
@Override
public void refreshToken(OAuth2Adapter adapter, String accessTokenId) throws Exception {
    if (StringUtils.isEmpty(accessTokenId)) {
        throw new IllegalArgumentException("Cannot refresh a blank accessTokenId");
    }

    String id = String.format("%s:%s:%s", this.getClass().getCanonicalName(), adapter.getName(), accessTokenId);
    Lock lock = this.muleContext.getLockFactory().createLock(id);
    lock.lock();
    try {
        if (!this.getRefreshedTokens().contains(id)) {
            adapter.refreshAccessToken(accessTokenId);
            this.getRefreshedTokens().store(id, true);
        }
    } finally {
        lock.unlock();
    }

}

From source file:org.springframework.integration.metadata.PropertiesPersistingMetadataStore.java

@Override
public String get(String key) {
    Assert.notNull(key, "'key' cannot be null");
    Lock lock = this.lockRegistry.obtain(key);
    lock.lock();//from   w w  w  .java 2s. c  om
    try {
        return this.metadata.getProperty(key);
    } finally {
        lock.unlock();
    }
}