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

com.github.sadstool.redissonaspectlock.lock.LockFactory Maven / Gradle / Ivy

There is a newer version: 1.1
Show newest version
package com.github.sadstool.redissonaspectlock.lock;

import com.github.sadstool.redissonaspectlock.attributes.LockAttributes;
import com.google.common.util.concurrent.Striped;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LockFactory {

    private static final Logger LOGGER = LoggerFactory.getLogger(LockFactory.class);
    
    private Striped striped; 


    public LockFactory() {
        striped = Striped.lazyWeakLock(32); //FIXME
    }

    public Lock create(LockAttributes attributes) {
        String path = attributes.getPath();
        long waitTime = attributes.getWaitTime();
        long leaseTime = attributes.getLeaseTime();

        LOGGER.trace("Creating lock with name '{}', path '{}', waitTime {} and leaseTime {}", attributes.getName(),
                path, waitTime, leaseTime);
        //RLock lock = redissonClient.getLock(path);
        java.util.concurrent.locks.Lock lock=striped.get(path);
        return new JavaLock(lock, waitTime, leaseTime);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy