All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jasmine.mock.framework.lock.MockDistributedDeclaredLock Maven / Gradle / Ivy

There is a newer version: 1.3.8
Show newest version
package jasmine.mock.framework.lock;

import jasmine.framework.common.util.CheckUtil;
import jasmine.framework.common.util.ErrorUtil;
import jasmine.framework.lock.distributed.DistributedDeclaredLock;
import jasmine.framework.lock.distributed.DistributedLockCallback;

/**
 * @author mh.z
 */
public class MockDistributedDeclaredLock implements DistributedDeclaredLock {

    @Override
    public  T lock(DistributedLockCallback callback) {
        CheckUtil.notNull(callback, "callback null");

        try {
            return (T) callback.call();
        } catch (Throwable e) {
            throw ErrorUtil.sneakyError(e);
        }
    }

    @Override
    public  T lock(long waitTime, DistributedLockCallback callback) {
        CheckUtil.notNull(callback, "callback null");

        try {
            return (T) callback.call();
        } catch (Throwable e) {
            throw ErrorUtil.sneakyError(e);
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy