Example usage for org.apache.commons.transaction.locking MultiLevelLock acquire

List of usage examples for org.apache.commons.transaction.locking MultiLevelLock acquire

Introduction

In this page you can find the example usage for org.apache.commons.transaction.locking MultiLevelLock acquire.

Prototype

public boolean acquire(Object ownerId, int targetLockLevel, boolean wait, boolean reentrant, long timeoutMSecs)
        throws InterruptedException;

Source Link

Document

Tries to acquire a certain lock level on this lock.

Usage

From source file:de.innovationgate.wgpublisher.WGPDeployer.java

public String locateTmlResource(WGTMLModule tmlLib, ServletRequest servletRequest)
        throws WGAPIException, DeployerException {

    DesignReference ref = WGADesignManager.createDesignReference(tmlLib);

    DeployedLayout layout = getDeployedLayout(tmlLib, ref);
    if (layout == null) {
        MultiLevelLock lock = _lockManager.atomicGetOrCreateLock(ref.toString());
        try {/*  w  w  w.ja  v a 2  s.  c  o m*/
            try {
                lock.acquire(Thread.currentThread(), 1, true, true, Long.MAX_VALUE);
            } catch (InterruptedException e) {
            }

            layout = getDeployedLayout(tmlLib, ref);
            if (layout == null) {
                servletRequest.setAttribute(REQATTRIB_TML_DEPLOYED, true);
                layout = deployTML(tmlLib);
            }
        } finally {
            lock.release(Thread.currentThread());
        }
    }

    return layout.getResourcePath();

}