com.nepxion.aquarius.lock.redis.impl.RedisLockDelegateImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aquarius-lock-redis Show documentation
Show all versions of aquarius-lock-redis Show documentation
Nepxion Aquarius is a list of distribution components based on Redis + Zookeeper with Nepxion Matrix AOP framework
package com.nepxion.aquarius.lock.redis.impl;
/**
* Title: Nepxion Aquarius
* Description: Nepxion Aquarius
* Copyright: Copyright (c) 2017-2050
* Company: Nepxion
* @author Haojun Ren
* @version 1.0
*/
import org.aopalliance.intercept.MethodInvocation;
import org.redisson.api.RLock;
import org.springframework.beans.factory.annotation.Autowired;
import com.nepxion.aquarius.lock.LockDelegate;
import com.nepxion.aquarius.lock.LockExecutor;
import com.nepxion.aquarius.lock.entity.LockType;
public class RedisLockDelegateImpl implements LockDelegate {
@Autowired
private LockExecutor lockExecutor;
@Override
public Object invoke(MethodInvocation invocation, LockType lockType, String key, long leaseTime, long waitTime, boolean async, boolean fair) throws Throwable {
RLock lock = null;
try {
lock = lockExecutor.tryLock(lockType, key, leaseTime, waitTime, async, fair);
if (lock != null) {
return invocation.proceed();
}
} finally {
lockExecutor.unlock(lock);
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy