提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.framework.lock4j.core; |
H |
2 |
|
|
3 |
import com.iailab.framework.common.exception.ServiceException; |
|
4 |
import com.iailab.framework.common.exception.enums.GlobalErrorCodeConstants; |
|
5 |
import com.baomidou.lock.LockFailureStrategy; |
|
6 |
import lombok.extern.slf4j.Slf4j; |
|
7 |
|
|
8 |
import java.lang.reflect.Method; |
|
9 |
|
|
10 |
/** |
|
11 |
* 自定义获取锁失败策略,抛出 {@link ServiceException} 异常 |
|
12 |
*/ |
|
13 |
@Slf4j |
|
14 |
public class DefaultLockFailureStrategy implements LockFailureStrategy { |
|
15 |
|
|
16 |
@Override |
|
17 |
public void onLockFailure(String key, Method method, Object[] arguments) { |
|
18 |
log.debug("[onLockFailure][线程:{} 获取锁失败,key:{} 获取失败:{} ]", Thread.currentThread().getName(), key, arguments); |
|
19 |
throw new ServiceException(GlobalErrorCodeConstants.LOCKED); |
|
20 |
} |
|
21 |
} |