Example usage for org.apache.commons.transaction.locking GenericLock getOwner

List of usage examples for org.apache.commons.transaction.locking GenericLock getOwner

Introduction

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

Prototype

public Object getOwner() 

Source Link

Usage

From source file:org.apache.slide.store.ExtendedStore.java

public void exclusiveTransientLock(String uri) throws ServiceAccessException {
    Xid txId = (Xid) activeTransactionBranch.get();
    if (txId != null) {
        try {//from   w ww  . j  av  a 2 s.com
            GenericLock lock = (GenericLock) lockManager.atomicGetOrCreateLock(uri);
            if (lock.getLockLevel(txId) != 1) {
                Object owner = lock.getOwner();
                getLogger().log(
                        "Try lock: " + txId + " tries " + uri
                                + (owner != null ? " ---> " + owner.toString() + " has it" : ""),
                        LOG_CHANNEL, Logger.DEBUG);
                if (!lock.acquire(txId, 1, true, true, timeout)) {
                    throw new ServiceAccessException(this, new ConflictException(uri));
                }
                ((HashSet) locks.get()).add(lock);
                getLogger().log("Has lock: " + txId + " locks " + uri, LOG_CHANNEL, Logger.DEBUG);
            }
        } catch (InterruptedException e) {
            throw new ServiceAccessException(this, new ConflictException(uri));
        }
    }
}