proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPermissionService.java | SysPermissionService | getMenuPermission | class SysPermissionService
{
@Autowired
private ISysRoleService roleService;
@Autowired
private ISysMenuService menuService;
/**
* 获取角色数据权限
*
* @param user 用户信息
* @return 角色权限信息
*/
public Set<String> getRolePermission(SysUser user)
{
Set<St... |
Set<String> perms = new HashSet<String>();
// 管理员拥有所有权限
if (user.isAdmin())
{
perms.add("*:*:*");
}
else
{
List<SysRole> roles = user.getRoles();
if (!CollectionUtils.isEmpty(roles))
{
//... | 298 | 255 | 553 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysRegisterService.java | SysRegisterService | validateCaptcha | class SysRegisterService
{
@Autowired
private ISysUserService userService;
@Autowired
private ISysConfigService configService;
@Autowired
private RedisCache redisCache;
/**
* 注册
*/
public String register(RegisterBody registerBody)
{
String msg = "... |
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
String captcha = redisCache.getCacheObject(verifyKey);
redisCache.deleteObject(verifyKey);
if (captcha == null)
{
throw new CaptchaExpireException();
}
if (!code.e... | 730 | 128 | 858 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java | TokenService | getLoginUser | class TokenService
{
private static final Logger log = LoggerFactory.getLogger(TokenService.class);
// 令牌自定义标识
@Value("${token.header}")
private String header;
// 令牌秘钥
@Value("${token.secret}")
private String secret;
// 令牌有效期(默认30分钟)
@Value("${token.expireTime}")
... |
// 获取请求携带的令牌
String token = getToken(request);
if (StringUtils.isNotEmpty(token))
{
try
{
Claims claims = parseToken(token);
// 解析对应的权限以及用户信息
String uuid = (String) claims.get(Constants.LOGIN_USER_KEY);
... | 1,598 | 189 | 1,787 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java | UserDetailsServiceImpl | loadUserByUsername | class UserDetailsServiceImpl implements UserDetailsService
{
private static final Logger log = LoggerFactory.getLogger(UserDetailsServiceImpl.class);
@Autowired
private ISysUserService userService;
@Autowired
private SysPasswordService passwordService;
@Autowired
private Sy... |
SysUser user = userService.selectUserByUserName(username);
if (StringUtils.isNull(user))
{
log.info("登录用户:{} 不存在.", username);
throw new ServiceException(MessageUtils.message("user.not.exists"));
}
else if (UserStatus.DELETED.getCode().equals(user.... | 201 | 247 | 448 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java | VelocityInitializer | initVelocity | class VelocityInitializer
{
/**
* 初始化vm方法
*/
public static void initVelocity()
{<FILL_FUNCTION_BODY>}
} |
Properties p = new Properties();
try
{
// 加载classpath目录下的vm文件
p.setProperty("resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
// 定义字符集
p.setProperty(Velocity.INPUT_ENCODING, Constants.UTF8... | 57 | 165 | 222 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java | SysJobController | edit | class SysJobController extends BaseController
{
@Autowired
private ISysJobService jobService;
/**
* 查询定时任务列表
*/
@PreAuthorize("@ss.hasPermi('monitor:job:list')")
@GetMapping("/list")
public TableDataInfo list(SysJob sysJob)
{
startPage();
List<SysJob> ... |
if (!CronUtils.isValid(job.getCronExpression()))
{
return error("修改任务'" + job.getJobName() + "'失败,Cron表达式不正确");
}
else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI))
{
return error("修改任务'" + job.getJobName() + "'失败... | 1,494 | 458 | 1,952 | <methods>public non-sealed void <init>() ,public com.ruoyi.common.core.domain.AjaxResult error() ,public com.ruoyi.common.core.domain.AjaxResult error(java.lang.String) ,public java.lang.Long getDeptId() ,public com.ruoyi.common.core.domain.model.LoginUser getLoginUser() ,public java.lang.Long getUserId() ,public java.... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java | SysJobLogController | export | class SysJobLogController extends BaseController
{
@Autowired
private ISysJobLogService jobLogService;
/**
* 查询定时任务调度日志列表
*/
@PreAuthorize("@ss.hasPermi('monitor:job:list')")
@GetMapping("/list")
public TableDataInfo list(SysJobLog sysJobLog)
{
startPage();
... |
List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
ExcelUtil<SysJobLog> util = new ExcelUtil<SysJobLog>(SysJobLog.class);
util.exportExcel(response, list, "调度日志");
| 629 | 78 | 707 | <methods>public non-sealed void <init>() ,public com.ruoyi.common.core.domain.AjaxResult error() ,public com.ruoyi.common.core.domain.AjaxResult error(java.lang.String) ,public java.lang.Long getDeptId() ,public com.ruoyi.common.core.domain.model.LoginUser getLoginUser() ,public java.lang.Long getUserId() ,public java.... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java | SysJob | toString | class SysJob extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 任务ID */
@Excel(name = "任务序号", cellType = ColumnType.NUMERIC)
private Long jobId;
/** 任务名称 */
@Excel(name = "任务名称")
private String jobName;
/** 任务组名 */
@Excel(name = "任务组名")
pri... |
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("jobId", getJobId())
.append("jobName", getJobName())
.append("jobGroup", getJobGroup())
.append("cronExpression", getCronExpression())
.append("nextValidTime", getNextValid... | 1,159 | 208 | 1,367 | <methods>public non-sealed void <init>() ,public java.lang.String getCreateBy() ,public java.util.Date getCreateTime() ,public Map<java.lang.String,java.lang.Object> getParams() ,public java.lang.String getRemark() ,public java.lang.String getSearchValue() ,public java.lang.String getUpdateBy() ,public java.util.Date g... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java | SysJobLog | toString | class SysJobLog extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** ID */
@Excel(name = "日志序号")
private Long jobLogId;
/** 任务名称 */
@Excel(name = "任务名称")
private String jobName;
/** 任务组名 */
@Excel(name = "任务组名")
private String jobGroup;
... |
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("jobLogId", getJobLogId())
.append("jobName", getJobName())
.append("jobGroup", getJobGroup())
.append("jobMessage", getJobMessage())
.append("status", getStatus())
... | 889 | 138 | 1,027 | <methods>public non-sealed void <init>() ,public java.lang.String getCreateBy() ,public java.util.Date getCreateTime() ,public Map<java.lang.String,java.lang.Object> getParams() ,public java.lang.String getRemark() ,public java.lang.String getSearchValue() ,public java.lang.String getUpdateBy() ,public java.util.Date g... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java | AbstractQuartzJob | after | class AbstractQuartzJob implements Job
{
private static final Logger log = LoggerFactory.getLogger(AbstractQuartzJob.class);
/**
* 线程本地变量
*/
private static ThreadLocal<Date> threadLocal = new ThreadLocal<>();
@Override
public void execute(JobExecutionContext context) throws Job... |
Date startTime = threadLocal.get();
threadLocal.remove();
final SysJobLog sysJobLog = new SysJobLog();
sysJobLog.setJobName(sysJob.getJobName());
sysJobLog.setJobGroup(sysJob.getJobGroup());
sysJobLog.setInvokeTarget(sysJob.getInvokeTarget());
sysJobLog.... | 524 | 338 | 862 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/CronUtils.java | CronUtils | getNextExecution | class CronUtils
{
/**
* 返回一个布尔值代表一个给定的Cron表达式的有效性
*
* @param cronExpression Cron表达式
* @return boolean 表达式是否有效
*/
public static boolean isValid(String cronExpression)
{
return CronExpression.isValidExpression(cronExpression);
}
/**
* 返回一个字符串值,表示该消息... |
try
{
CronExpression cron = new CronExpression(cronExpression);
return cron.getNextValidTimeAfter(new Date(System.currentTimeMillis()));
}
catch (ParseException e)
{
throw new IllegalArgumentException(e.getMessage());
}
| 348 | 84 | 432 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java | JobInvokeUtil | getMethodParams | class JobInvokeUtil
{
/**
* 执行方法
*
* @param sysJob 系统任务
*/
public static void invokeMethod(SysJob sysJob) throws Exception
{
String invokeTarget = sysJob.getInvokeTarget();
String beanName = getBeanName(invokeTarget);
String methodName = getMethodName(i... |
String methodStr = StringUtils.substringBetween(invokeTarget, "(", ")");
if (StringUtils.isEmpty(methodStr))
{
return null;
}
String[] methodParams = methodStr.split(",(?=([^\"']*[\"'][^\"']*[\"'])*[^\"']*$)");
List<Object[]> classs = new LinkedList<>(... | 1,148 | 516 | 1,664 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleUtils.java | ScheduleUtils | createScheduleJob | class ScheduleUtils
{
/**
* 得到quartz任务类
*
* @param sysJob 执行计划
* @return 具体执行任务类
*/
private static Class<? extends Job> getQuartzJobClass(SysJob sysJob)
{
boolean isConcurrent = "0".equals(sysJob.getConcurrent());
return isConcurrent ? QuartzJobExecution.c... |
Class<? extends Job> jobClass = getQuartzJobClass(job);
// 构建job信息
Long jobId = job.getJobId();
String jobGroup = job.getJobGroup();
JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(getJobKey(jobId, jobGroup)).build();
// 表达式调度构建器
CronSched... | 873 | 481 | 1,354 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysConfig.java | SysConfig | toString | class SysConfig extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 参数主键 */
@Excel(name = "参数主键", cellType = ColumnType.NUMERIC)
private Long configId;
/** 参数名称 */
@Excel(name = "参数名称")
private String configName;
/** 参数键名 */
@Excel(name = "参数键名")... |
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("configId", getConfigId())
.append("configName", getConfigName())
.append("configKey", getConfigKey())
.append("configValue", getConfigValue())
.append("configType", getConf... | 706 | 163 | 869 | <methods>public non-sealed void <init>() ,public java.lang.String getCreateBy() ,public java.util.Date getCreateTime() ,public Map<java.lang.String,java.lang.Object> getParams() ,public java.lang.String getRemark() ,public java.lang.String getSearchValue() ,public java.lang.String getUpdateBy() ,public java.util.Date g... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java | SysNotice | toString | class SysNotice extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 公告ID */
private Long noticeId;
/** 公告标题 */
private String noticeTitle;
/** 公告类型(1通知 2公告) */
private String noticeType;
/** 公告内容 */
private String noticeContent;
/** 公告状态... |
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("noticeId", getNoticeId())
.append("noticeTitle", getNoticeTitle())
.append("noticeType", getNoticeType())
.append("noticeContent", getNoticeContent())
.append("status", get... | 530 | 165 | 695 | <methods>public non-sealed void <init>() ,public java.lang.String getCreateBy() ,public java.util.Date getCreateTime() ,public Map<java.lang.String,java.lang.Object> getParams() ,public java.lang.String getRemark() ,public java.lang.String getSearchValue() ,public java.lang.String getUpdateBy() ,public java.util.Date g... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java | SysPost | toString | class SysPost extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 岗位序号 */
@Excel(name = "岗位序号", cellType = ColumnType.NUMERIC)
private Long postId;
/** 岗位编码 */
@Excel(name = "岗位编码")
private String postCode;
/** 岗位名称 */
@Excel(name = "岗位名称")
... |
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("postId", getPostId())
.append("postCode", getPostCode())
.append("postName", getPostName())
.append("postSort", getPostSort())
.append("status", getStatus())
.... | 742 | 161 | 903 | <methods>public non-sealed void <init>() ,public java.lang.String getCreateBy() ,public java.util.Date getCreateTime() ,public Map<java.lang.String,java.lang.Object> getParams() ,public java.lang.String getRemark() ,public java.lang.String getSearchValue() ,public java.lang.String getUpdateBy() ,public java.util.Date g... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java | SysConfigServiceImpl | selectConfigByKey | class SysConfigServiceImpl implements ISysConfigService
{
@Autowired
private SysConfigMapper configMapper;
@Autowired
private RedisCache redisCache;
/**
* 项目启动时,初始化参数到缓存
*/
@PostConstruct
public void init()
{
loadingConfigCache();
}
/**
... |
String configValue = Convert.toStr(redisCache.getCacheObject(getCacheKey(configKey)));
if (StringUtils.isNotEmpty(configValue))
{
return configValue;
}
SysConfig config = new SysConfig();
config.setConfigKey(configKey);
SysConfig retConfig = c... | 1,604 | 172 | 1,776 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java | SysDictDataServiceImpl | deleteDictDataByIds | class SysDictDataServiceImpl implements ISysDictDataService
{
@Autowired
private SysDictDataMapper dictDataMapper;
/**
* 根据条件分页查询字典数据
*
* @param dictData 字典数据信息
* @return 字典数据集合信息
*/
@Override
public List<SysDictData> selectDictDataList(SysDictData dictData)
... |
for (Long dictCode : dictCodes)
{
SysDictData data = selectDictDataById(dictCode);
dictDataMapper.deleteDictDataById(dictCode);
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
DictUtils.setDictCache(data.getDic... | 807 | 116 | 923 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java | SysDictTypeServiceImpl | checkDictTypeUnique | class SysDictTypeServiceImpl implements ISysDictTypeService
{
@Autowired
private SysDictTypeMapper dictTypeMapper;
@Autowired
private SysDictDataMapper dictDataMapper;
/**
* 项目启动时,初始化字典到缓存
*/
@PostConstruct
public void init()
{
loadingDictCache();
}... |
Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId();
SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType());
if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue())
{
return UserConsta... | 1,755 | 131 | 1,886 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java | SysPostServiceImpl | checkPostCodeUnique | class SysPostServiceImpl implements ISysPostService
{
@Autowired
private SysPostMapper postMapper;
@Autowired
private SysUserPostMapper userPostMapper;
/**
* 查询岗位信息集合
*
* @param post 岗位信息
* @return 岗位信息集合
*/
@Override
public List<SysPost> selectPost... |
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
SysPost info = postMapper.checkPostCodeUnique(post.getPostCode());
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue())
{
return UserConstants.NOT_UNIQUE;
... | 1,201 | 120 | 1,321 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java | SysUserOnlineServiceImpl | selectOnlineByInfo | class SysUserOnlineServiceImpl implements ISysUserOnlineService
{
/**
* 通过登录地址查询信息
*
* @param ipaddr 登录地址
* @param user 用户信息
* @return 在线用户信息
*/
@Override
public SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user)
{
if (StringUtils.equals(... |
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername()))
{
return loginUserToUserOnline(user);
}
return null;
| 727 | 65 | 792 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/cdi/shedlock-cdi-vintage/src/main/java/net/javacrumbs/shedlock/cdi/internal/CdiLockConfigurationExtractor.java | CdiLockConfigurationExtractor | getValue | class CdiLockConfigurationExtractor {
private final Duration defaultLockAtMostFor;
private final Duration defaultLockAtLeastFor;
CdiLockConfigurationExtractor(Duration defaultLockAtMostFor, Duration defaultLockAtLeastFor) {
this.defaultLockAtMostFor = requireNonNull(defaultLockAtMostFor);
t... |
if (!stringValueFromAnnotation.isEmpty()) {
return parseDuration(stringValueFromAnnotation);
} else {
return defaultValue;
}
| 408 | 40 | 448 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/cdi/shedlock-cdi-vintage/src/main/java/net/javacrumbs/shedlock/cdi/internal/SchedulerLockInterceptor.java | SchedulerLockInterceptor | lock | class SchedulerLockInterceptor {
private final LockingTaskExecutor lockingTaskExecutor;
private final CdiLockConfigurationExtractor lockConfigurationExtractor;
@Inject
public SchedulerLockInterceptor(LockProvider lockProvider) {
this.lockingTaskExecutor = new DefaultLockingTaskExecutor(lockProv... |
Class<?> returnType = context.getMethod().getReturnType();
if (!void.class.equals(returnType) && !Void.class.equals(returnType)) {
throw new LockingNotSupportedException();
}
Optional<LockConfiguration> lockConfiguration =
lockConfigurationExtractor.getLockC... | 294 | 148 | 442 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/cdi/shedlock-cdi-vintage/src/main/java/net/javacrumbs/shedlock/cdi/internal/Utils.java | Utils | parseDuration | class Utils {
static Duration parseDuration(String value) {<FILL_FUNCTION_BODY>}
} |
value = value.trim();
if (value.isEmpty()) {
return null;
}
try {
return Duration.parse(value);
} catch (DateTimeParseException e) {
throw new IllegalArgumentException(e);
}
| 31 | 66 | 97 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/cdi/shedlock-cdi/src/main/java/net/javacrumbs/shedlock/cdi/internal/CdiLockConfigurationExtractor.java | CdiLockConfigurationExtractor | getValue | class CdiLockConfigurationExtractor {
private final Duration defaultLockAtMostFor;
private final Duration defaultLockAtLeastFor;
CdiLockConfigurationExtractor(Duration defaultLockAtMostFor, Duration defaultLockAtLeastFor) {
this.defaultLockAtMostFor = requireNonNull(defaultLockAtMostFor);
t... |
if (!stringValueFromAnnotation.isEmpty()) {
return parseDuration(stringValueFromAnnotation);
} else {
return defaultValue;
}
| 408 | 40 | 448 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/cdi/shedlock-cdi/src/main/java/net/javacrumbs/shedlock/cdi/internal/SchedulerLockInterceptor.java | SchedulerLockInterceptor | lock | class SchedulerLockInterceptor {
private final LockingTaskExecutor lockingTaskExecutor;
private final CdiLockConfigurationExtractor lockConfigurationExtractor;
@Inject
public SchedulerLockInterceptor(LockProvider lockProvider) {
this.lockingTaskExecutor = new DefaultLockingTaskExecutor(lockProv... |
Class<?> returnType = context.getMethod().getReturnType();
if (!void.class.equals(returnType) && !Void.class.equals(returnType)) {
throw new LockingNotSupportedException();
}
Optional<LockConfiguration> lockConfiguration =
lockConfigurationExtractor.getLockC... | 294 | 148 | 442 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/cdi/shedlock-cdi/src/main/java/net/javacrumbs/shedlock/cdi/internal/Utils.java | Utils | parseDuration | class Utils {
static Duration parseDuration(String value) {<FILL_FUNCTION_BODY>}
} |
value = value.trim();
if (value.isEmpty()) {
return null;
}
try {
return Duration.parse(value);
} catch (DateTimeParseException e) {
throw new IllegalArgumentException(e);
}
| 31 | 66 | 97 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/micronaut/shedlock-micronaut/src/main/java/net/javacrumbs/shedlock/micronaut/internal/MicronautLockConfigurationExtractor.java | MicronautLockConfigurationExtractor | getValue | class MicronautLockConfigurationExtractor {
private final Duration defaultLockAtMostFor;
private final Duration defaultLockAtLeastFor;
private final ConversionService<?> conversionService;
MicronautLockConfigurationExtractor(
Duration defaultLockAtMostFor, Duration defaultLockAtLeastFor, Co... |
String stringValueFromAnnotation =
annotation.get(paramName, String.class).orElse("");
if (StringUtils.hasText(stringValueFromAnnotation)) {
return conversionService
.convert(stringValueFromAnnotation, Duration.class)
.orElseThrow(() -... | 477 | 119 | 596 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/micronaut/shedlock-micronaut/src/main/java/net/javacrumbs/shedlock/micronaut/internal/SchedulerLockInterceptor.java | SchedulerLockInterceptor | intercept | class SchedulerLockInterceptor implements MethodInterceptor<Object, Object> {
private final LockingTaskExecutor lockingTaskExecutor;
private final MicronautLockConfigurationExtractor micronautLockConfigurationExtractor;
public SchedulerLockInterceptor(
LockProvider lockProvider,
Opt... |
Class<?> returnType = context.getReturnType().getType();
if (!void.class.equals(returnType) && !Void.class.equals(returnType)) {
throw new LockingNotSupportedException();
}
Optional<LockConfiguration> lockConfiguration =
micronautLockConfigurationExtractor.g... | 357 | 150 | 507 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/micronaut/shedlock-micronaut4/src/main/java/net/javacrumbs/shedlock/micronaut/internal/MicronautLockConfigurationExtractor.java | MicronautLockConfigurationExtractor | getValue | class MicronautLockConfigurationExtractor {
private final Duration defaultLockAtMostFor;
private final Duration defaultLockAtLeastFor;
private final ConversionService conversionService;
MicronautLockConfigurationExtractor(
Duration defaultLockAtMostFor, Duration defaultLockAtLeastFor, Conve... |
String stringValueFromAnnotation =
annotation.get(paramName, String.class).orElse("");
if (StringUtils.hasText(stringValueFromAnnotation)) {
return conversionService
.convert(stringValueFromAnnotation, Duration.class)
.orElseThrow(() -... | 471 | 119 | 590 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/micronaut/shedlock-micronaut4/src/main/java/net/javacrumbs/shedlock/micronaut/internal/SchedulerLockInterceptor.java | SchedulerLockInterceptor | convert | class SchedulerLockInterceptor implements MethodInterceptor<Object, Object> {
private final LockingTaskExecutor lockingTaskExecutor;
private final MicronautLockConfigurationExtractor micronautLockConfigurationExtractor;
public SchedulerLockInterceptor(
LockProvider lockProvider,
Opt... |
return resolvedConversionService
.convert(defaultLockAtMostFor, Duration.class)
.orElseThrow(() -> new IllegalArgumentException("Invalid '" + label + "' value"));
| 545 | 48 | 593 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/arangodb/shedlock-provider-arangodb/src/main/java/net/javacrumbs/shedlock/provider/arangodb/ArangoLockProvider.java | ArangoLockProvider | lock | class ArangoLockProvider implements LockProvider {
static final String LOCK_UNTIL = "lockUntil";
static final String LOCKED_AT = "lockedAt";
static final String LOCKED_BY = "lockedBy";
static final String COLLECTION_NAME = "shedLock";
private final ArangoCollection arangoCollection;
/**
... |
String transactionId = null;
try {
/*
* Transaction is necessary because repsert (insert with overwrite=true in
* arangodb) is not possible with condition check (see case 2 description below)
*/
StreamTransactionEntity streamTransactionEnt... | 774 | 512 | 1,286 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/cassandra/shedlock-provider-cassandra/src/main/java/net/javacrumbs/shedlock/provider/cassandra/CassandraLockProvider.java | Builder | build | class Builder {
private CqlIdentifier table = CqlIdentifier.fromCql(DEFAULT_TABLE);
private ColumnNames columnNames = new ColumnNames("name", "lockUntil", "lockedAt", "lockedBy");
private CqlSession cqlSession;
private ConsistencyLevel consistencyLevel = ConsistencyLevel.... |
return new CassandraLockProvider.Configuration(
cqlSession, table, columnNames, consistencyLevel, serialConsistencyLevel, keyspace);
| 456 | 37 | 493 | <methods>public void clearCache() ,public Optional<net.javacrumbs.shedlock.core.SimpleLock> lock(net.javacrumbs.shedlock.core.LockConfiguration) <variables>private final net.javacrumbs.shedlock.support.LockRecordRegistry lockRecordRegistry,private final non-sealed net.javacrumbs.shedlock.support.StorageAccessor storage... |
lukas-krecan_ShedLock | ShedLock/providers/cassandra/shedlock-provider-cassandra/src/main/java/net/javacrumbs/shedlock/provider/cassandra/CassandraStorageAccessor.java | CassandraStorageAccessor | find | class CassandraStorageAccessor extends AbstractStorageAccessor {
private final String hostname;
private final CqlIdentifier table;
private final CqlIdentifier keyspace;
private final String lockName;
private final String lockUntil;
private final String lockedAt;
private final String lockedBy... |
SimpleStatement selectStatement = QueryBuilder.selectFrom(keyspace, table)
.column(lockUntil)
.column(lockedAt)
.column(lockedBy)
.whereColumn(lockName)
.isEqualTo(literal(name))
.build()
.setConsist... | 1,316 | 191 | 1,507 | <methods>public non-sealed void <init>() <variables>protected final Logger logger |
lukas-krecan_ShedLock | ShedLock/providers/couchbase/shedlock-provider-couchbase-javaclient3/src/main/java/net/javacrumbs/shedlock/provider/couchbase/javaclient3/CouchbaseLockProvider.java | CouchbaseAccessor | updateRecord | class CouchbaseAccessor extends AbstractStorageAccessor {
private final Collection collection;
CouchbaseAccessor(Collection collection) {
this.collection = collection;
}
@Override
public boolean insertRecord(@NonNull LockConfiguration lockConfiguration) {
... |
GetResult result = collection.get(lockConfiguration.getName());
JsonObject document = result.contentAsObject();
Instant lockUntil = parse(document.get(LOCK_UNTIL));
Instant now = ClockProvider.now();
if (lockUntil.isAfter(now)) {
return false... | 551 | 205 | 756 | <methods>public void clearCache() ,public Optional<net.javacrumbs.shedlock.core.SimpleLock> lock(net.javacrumbs.shedlock.core.LockConfiguration) <variables>private final net.javacrumbs.shedlock.support.LockRecordRegistry lockRecordRegistry,private final non-sealed net.javacrumbs.shedlock.support.StorageAccessor storage... |
lukas-krecan_ShedLock | ShedLock/providers/datastore/shedlock-provider-datastore/src/main/java/net/javacrumbs/shedlock/provider/datastore/DatastoreStorageAccessor.java | DatastoreStorageAccessor | updateOwn | class DatastoreStorageAccessor extends AbstractStorageAccessor {
private static final Logger log = LoggerFactory.getLogger(DatastoreStorageAccessor.class);
private final Datastore datastore;
private final String hostname;
private final String entityName;
private final DatastoreLockProvider.FieldNam... |
return doInTxn(txn -> get(name, txn)
.filter(entity -> this.hostname.equals(nullableString(entity, this.fieldNames.lockedBy())))
.filter(entity -> {
var now = ClockProvider.now();
var lockUntilTs = nullableT... | 1,311 | 195 | 1,506 | <methods>public non-sealed void <init>() <variables>protected final Logger logger |
lukas-krecan_ShedLock | ShedLock/providers/dynamodb/shedlock-provider-dynamodb2/src/main/java/net/javacrumbs/shedlock/provider/dynamodb2/DynamoDBLockProvider.java | DynamoDBLockProvider | lock | class DynamoDBLockProvider implements LockProvider {
static final String LOCK_UNTIL = "lockUntil";
static final String LOCKED_AT = "lockedAt";
static final String LOCKED_BY = "lockedBy";
static final String ID = "_id";
private static final String OBTAIN_LOCK_QUERY =
"set " + LOCK_UNTIL ... |
String nowIso = toIsoString(now());
String lockUntilIso = toIsoString(lockConfiguration.getLockAtMostUntil());
Map<String, AttributeValue> key = singletonMap(ID, attr(lockConfiguration.getName()));
Map<String, AttributeValue> attributeUpdates =
Map.of(":lockUntil", att... | 809 | 380 | 1,189 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/dynamodb/shedlock-provider-dynamodb2/src/main/java/net/javacrumbs/shedlock/provider/dynamodb2/DynamoDBUtils.java | DynamoDBUtils | createLockTable | class DynamoDBUtils {
/**
* Creates a locking table with the given name.
*
* <p>
* This method does not check if a table with the given name exists already.
*
* @param ddbClient
* v2 of DynamoDBClient
* @param tableName
* table to be used
* @p... |
CreateTableRequest request = CreateTableRequest.builder()
.tableName(tableName)
.keySchema(KeySchemaElement.builder()
.attributeName(ID)
.keyType(KeyType.HASH)
.build())
.attributeDefinition... | 215 | 136 | 351 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/elasticsearch/shedlock-provider-elasticsearch8/src/main/java/net/javacrumbs/shedlock/provider/elasticsearch8/ElasticsearchLockProvider.java | ElasticsearchLockProvider | lock | class ElasticsearchLockProvider implements LockProvider {
static final String SCHEDLOCK_DEFAULT_INDEX = "shedlock";
static final String LOCK_UNTIL = "lockUntil";
static final String LOCKED_AT = "lockedAt";
static final String LOCKED_BY = "lockedBy";
static final String NAME = "name";
private st... |
try {
Instant now = now();
Instant lockAtMostUntil = lockConfiguration.getLockAtMostUntil();
Map<String, JsonData> lockObject = lockObject(lockConfiguration.getName(), lockAtMostUntil, now);
// The object exist only to have some type we can work with
... | 983 | 384 | 1,367 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/etcd/shedlock-provider-etcd-jetcd/src/main/java/net/javacrumbs/shedlock/provider/etcd/jetcd/EtcdLockProvider.java | EtcdTemplate | revoke | class EtcdTemplate {
private final KV kvClient;
private final Lease leaseClient;
private EtcdTemplate(Client client) {
this.kvClient = client.getKVClient();
this.leaseClient = client.getLeaseClient();
}
public Long createLease(long lockUntilInSeconds) {
... |
try {
leaseClient.revoke(leaseId).get();
} catch (Exception e) {
throw new LockException("Failed to revoke lease " + leaseId, e);
}
| 724 | 51 | 775 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/hazelcast/shedlock-provider-hazelcast4/src/main/java/net/javacrumbs/shedlock/provider/hazelcast4/HazelcastLock.java | HazelcastLock | toString | class HazelcastLock implements Serializable {
private final String name;
private final Instant lockAtMostUntil;
private final Instant lockAtLeastUntil;
/**
* Moment when the lock is expired, so unlockable. The first value of this is
* {@link #lockAtMostUntil}.
*/
private final Ins... |
return "HazelcastLock{" + "name='" + name + '\'' + ", lockAtMostUntil=" + lockAtMostUntil
+ ", lockAtLeastUntil=" + lockAtLeastUntil + ", timeToLive=" + timeToLive + '}';
| 562 | 68 | 630 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/hazelcast/shedlock-provider-hazelcast4/src/main/java/net/javacrumbs/shedlock/provider/hazelcast4/HazelcastLockProvider.java | HazelcastLockProvider | lock | class HazelcastLockProvider implements LockProvider {
private static final Logger log = LoggerFactory.getLogger(HazelcastLockProvider.class);
static final String LOCK_STORE_KEY_DEFAULT = "shedlock_storage";
private static final Duration DEFAULT_LOCK_LEASE_TIME = Duration.ofSeconds(30);
/**
* Key... |
log.trace("lock - Attempt : {}", lockConfiguration);
final Instant now = ClockProvider.now();
final String lockName = lockConfiguration.getName();
final IMap<String, HazelcastLock> store = getStore();
try {
// lock the map key entry
store.lock(lockName, k... | 1,671 | 200 | 1,871 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/ignite/shedlock-provider-ignite/src/main/java/net/javacrumbs/shedlock/provider/ignite/IgniteLockProvider.java | IgniteLockProvider | extend | class IgniteLockProvider implements ExtensibleLockProvider {
/** Default ShedLock cache name. */
public static final String DEFAULT_SHEDLOCK_CACHE_NAME = "shedLock";
/** ShedLock cache. */
private final IgniteCache<String, LockValue> cache;
/**
* @param ignite
* Ignite instanc... |
Instant now = Instant.now();
String key = lockCfg.getName();
LockValue oldVal = cache.get(key);
if (oldVal == null
|| !oldVal.getLockedBy().equals(getHostname())
|| !oldVal.getLockUntil().isAfter(now)) return Optional.empty();
LockValue newVal ... | 924 | 153 | 1,077 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/inmemory/shedlock-provider-inmemory/src/main/java/net/javacrumbs/shedlock/provider/inmemory/InMemoryLockProvider.java | InMemoryLockProvider | doExtend | class InMemoryLockProvider implements ExtensibleLockProvider {
private final Map<String, LockRecord> locks = new HashMap<>();
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public Optional<SimpleLock> lock(LockConfiguration lockConfiguration) {
synchronized (locks... |
synchronized (locks) {
String lockName = newConfiguration.getName();
if (isLocked(lockName)) {
locks.put(lockName, new LockRecord(newConfiguration.getLockAtMostUntil()));
logger.debug("Extended {}", newConfiguration);
return Optional.of(ne... | 476 | 102 | 578 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/jdbc/shedlock-provider-jdbc-internal/src/main/java/net/javacrumbs/shedlock/provider/jdbc/internal/AbstractJdbcStorageAccessor.java | AbstractJdbcStorageAccessor | insertRecord | class AbstractJdbcStorageAccessor extends AbstractStorageAccessor {
private final String tableName;
public AbstractJdbcStorageAccessor(@NonNull String tableName) {
this.tableName = requireNonNull(tableName, "tableName can not be null");
}
@Override
public boolean insertRecord(@NonNull Lock... |
// Try to insert if the record does not exist (not optimal, but the simplest
// platform agnostic
// way)
String sql = "INSERT INTO " + tableName + "(name, lock_until, locked_at, locked_by) VALUES(?, ?, ?, ?)";
return executeCommand(
sql,
statemen... | 924 | 190 | 1,114 | <methods>public non-sealed void <init>() <variables>protected final Logger logger |
lukas-krecan_ShedLock | ShedLock/providers/jdbc/shedlock-provider-jdbc-micronaut/src/main/java/net/javacrumbs/shedlock/provider/jdbc/micronaut/MicronautJdbcStorageAccessor.java | MicronautJdbcStorageAccessor | executeCommand | class MicronautJdbcStorageAccessor extends AbstractJdbcStorageAccessor {
private final TransactionOperations<Connection> transactionManager;
private final TransactionDefinition.Propagation propagation = TransactionDefinition.Propagation.REQUIRES_NEW;
MicronautJdbcStorageAccessor(
@NonNull Tran... |
return transactionManager.execute(TransactionDefinition.of(propagation), status -> {
try (PreparedStatement statement = status.getConnection().prepareStatement(sql)) {
return body.apply(statement);
} catch (SQLException e) {
return exceptionHandler.apply(... | 187 | 82 | 269 | <methods>public void <init>(java.lang.String) ,public boolean extend(net.javacrumbs.shedlock.core.LockConfiguration) ,public boolean insertRecord(net.javacrumbs.shedlock.core.LockConfiguration) ,public void unlock(net.javacrumbs.shedlock.core.LockConfiguration) ,public boolean updateRecord(net.javacrumbs.shedlock.core.... |
lukas-krecan_ShedLock | ShedLock/providers/jdbc/shedlock-provider-jdbc-template/src/main/java/net/javacrumbs/shedlock/provider/jdbctemplate/JdbcTemplateLockProvider.java | Builder | build | class Builder {
private JdbcTemplate jdbcTemplate;
private DatabaseProduct databaseProduct;
private PlatformTransactionManager transactionManager;
private String tableName = DEFAULT_TABLE_NAME;
private TimeZone timeZone;
private String lockedByValu... |
return new JdbcTemplateLockProvider.Configuration(
jdbcTemplate,
databaseProduct,
transactionManager,
dbUpperCase ? tableName.toUpperCase() : tableName,
timeZone,
... | 670 | 99 | 769 | <methods>public void clearCache() ,public Optional<net.javacrumbs.shedlock.core.SimpleLock> lock(net.javacrumbs.shedlock.core.LockConfiguration) <variables>private final net.javacrumbs.shedlock.support.LockRecordRegistry lockRecordRegistry,private final non-sealed net.javacrumbs.shedlock.support.StorageAccessor storage... |
lukas-krecan_ShedLock | ShedLock/providers/jdbc/shedlock-provider-jdbc-template/src/main/java/net/javacrumbs/shedlock/provider/jdbctemplate/JdbcTemplateStorageAccessor.java | JdbcTemplateStorageAccessor | unlock | class JdbcTemplateStorageAccessor extends AbstractStorageAccessor {
private final NamedParameterJdbcTemplate jdbcTemplate;
private final TransactionTemplate transactionTemplate;
private final Configuration configuration;
private SqlStatementsSource sqlStatementsSource;
JdbcTemplateStorageAccessor(@... |
for (int i = 0; i < 10; i++) {
try {
doUnlock(lockConfiguration);
return;
} catch (ConcurrencyFailureException | TransactionSystemException e) {
logger.info("Unlock failed due to TransactionSystemException - retrying attempt {}", i + 1);
... | 889 | 86 | 975 | <methods>public non-sealed void <init>() <variables>protected final Logger logger |
lukas-krecan_ShedLock | ShedLock/providers/jdbc/shedlock-provider-jdbc-template/src/main/java/net/javacrumbs/shedlock/provider/jdbctemplate/OracleServerTimeStatementsSource.java | OracleServerTimeStatementsSource | params | class OracleServerTimeStatementsSource extends SqlStatementsSource {
private static final String now = "SYS_EXTRACT_UTC(SYSTIMESTAMP)";
private static final String lockAtMostFor = now + " + :lockAtMostFor";
private static final long millisecondsInDay = 24 * 60 * 60 * 1000;
OracleServerTimeStatementsSo... |
return Map.of(
"name",
lockConfiguration.getName(),
"lockedBy",
configuration.getLockedByValue(),
"lockAtMostFor",
((double) lockConfiguration.getLockAtMostFor().toMillis()) / millisecondsInDay,
"loc... | 656 | 107 | 763 | <methods>public java.lang.String getExtendStatement() ,public java.lang.String getUnlockStatement() ,public java.lang.String getUpdateStatement() <variables>protected final non-sealed net.javacrumbs.shedlock.provider.jdbctemplate.JdbcTemplateLockProvider.Configuration configuration,private static final Logger logger |
lukas-krecan_ShedLock | ShedLock/providers/jdbc/shedlock-provider-jdbc-template/src/main/java/net/javacrumbs/shedlock/provider/jdbctemplate/PostgresSqlStatementsSource.java | PostgresSqlStatementsSource | getInsertStatement | class PostgresSqlStatementsSource extends SqlStatementsSource {
PostgresSqlStatementsSource(JdbcTemplateLockProvider.Configuration configuration) {
super(configuration);
}
@Override
String getInsertStatement() {<FILL_FUNCTION_BODY>}
} |
return super.getInsertStatement() + " ON CONFLICT (" + name() + ") DO UPDATE " + "SET " + lockUntil()
+ " = :lockUntil, " + lockedAt() + " = :now, " + lockedBy() + " = :lockedBy " + "WHERE " + tableName()
+ "." + lockUntil() + " <= :now";
| 69 | 92 | 161 | <methods>public java.lang.String getExtendStatement() ,public java.lang.String getUnlockStatement() ,public java.lang.String getUpdateStatement() <variables>protected final non-sealed net.javacrumbs.shedlock.provider.jdbctemplate.JdbcTemplateLockProvider.Configuration configuration,private static final Logger logger |
lukas-krecan_ShedLock | ShedLock/providers/jdbc/shedlock-provider-jdbc-template/src/main/java/net/javacrumbs/shedlock/provider/jdbctemplate/SqlStatementsSource.java | SqlStatementsSource | getDatabaseProduct | class SqlStatementsSource {
protected final Configuration configuration;
private static final Logger logger = LoggerFactory.getLogger(SqlStatementsSource.class);
SqlStatementsSource(Configuration configuration) {
this.configuration = configuration;
}
static SqlStatementsSource create(Conf... |
if (configuration.getDatabaseProduct() != null) {
return configuration.getDatabaseProduct();
}
try {
String jdbcProductName = configuration.getJdbcTemplate().execute((ConnectionCallback<String>)
connection -> connection.getMetaData().getDatabaseProduc... | 872 | 129 | 1,001 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/jdbc/shedlock-provider-jdbc/src/main/java/net/javacrumbs/shedlock/provider/jdbc/JdbcStorageAccessor.java | JdbcStorageAccessor | executeCommand | class JdbcStorageAccessor extends AbstractJdbcStorageAccessor {
private final DataSource dataSource;
JdbcStorageAccessor(@NonNull DataSource dataSource, @NonNull String tableName) {
super(tableName);
this.dataSource = requireNonNull(dataSource, "dataSource can not be null");
}
@Overrid... |
try (Connection connection = dataSource.getConnection()) {
boolean originalAutocommit = connection.getAutoCommit();
if (!originalAutocommit) {
connection.setAutoCommit(true);
}
try (PreparedStatement statement = connection.prepareStatement(sql)) {... | 140 | 167 | 307 | <methods>public void <init>(java.lang.String) ,public boolean extend(net.javacrumbs.shedlock.core.LockConfiguration) ,public boolean insertRecord(net.javacrumbs.shedlock.core.LockConfiguration) ,public void unlock(net.javacrumbs.shedlock.core.LockConfiguration) ,public boolean updateRecord(net.javacrumbs.shedlock.core.... |
lukas-krecan_ShedLock | ShedLock/providers/jdbc/shedlock-provider-jooq/src/main/java/net/javacrumbs/shedlock/provider/jooq/JooqStorageAccessor.java | JooqStorageAccessor | extend | class JooqStorageAccessor extends AbstractStorageAccessor {
private final DSLContext dslContext;
private final Shedlock t = SHEDLOCK;
JooqStorageAccessor(DSLContext dslContext) {
this.dslContext = dslContext;
}
@Override
public boolean insertRecord(@NonNull LockConfiguration lockConfig... |
return dslContext.transactionResult(tx -> tx.dsl()
.update(t)
.set(t.LOCK_UNTIL, nowPlus(lockConfiguration.getLockAtMostFor()))
.where(t.NAME.eq(lockConfiguration.getName())
.and(t.LOCKED_BY.eq(getHostname()... | 610 | 113 | 723 | <methods>public non-sealed void <init>() <variables>protected final Logger logger |
lukas-krecan_ShedLock | ShedLock/providers/memcached/shedlock-provider-memcached-spy/src/main/java/net/javacrumbs/shedlock/provider/memcached/spy/MemcachedLockProvider.java | MemcachedLockProvider | lock | class MemcachedLockProvider implements LockProvider {
/** KEY PREFIX */
private static final String KEY_PREFIX = "shedlock";
/** ENV DEFAULT */
private static final String ENV_DEFAULT = "default";
private final MemcachedClient client;
private final String env;
/**
* Create Memcache... |
long expireTime = getSecondUntil(lockConfiguration.getLockAtMostUntil());
String key = buildKey(lockConfiguration.getName(), this.env);
OperationStatus status = client.add(key, (int) expireTime, buildValue()).getStatus();
if (status.isSuccess()) {
return Optional.of(new Memc... | 735 | 105 | 840 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/mongo/shedlock-provider-mongo-reactivestreams/src/main/java/net/javacrumbs/shedlock/provider/mongo/reactivestreams/ReactiveStreamsMongoLockProvider.java | ReactiveStreamsMongoLockProvider | lock | class ReactiveStreamsMongoLockProvider implements ExtensibleLockProvider {
static final String LOCK_UNTIL = "lockUntil";
static final String LOCKED_AT = "lockedAt";
static final String LOCKED_BY = "lockedBy";
static final String ID = "_id";
static final String DEFAULT_SHEDLOCK_COLLECTION_NAME = "she... |
Instant now = now();
Bson update = combine(
set(LOCK_UNTIL, lockConfiguration.getLockAtMostUntil()), set(LOCKED_AT, now), set(LOCKED_BY, hostname));
try {
// There are three possible situations:
// 1. The lock document does not exist yet - it is inserted ... | 879 | 307 | 1,186 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/mongo/shedlock-provider-mongo-reactivestreams/src/main/java/net/javacrumbs/shedlock/provider/mongo/reactivestreams/SingleLockableSubscriber.java | SingleLockableSubscriber | await | class SingleLockableSubscriber<T> implements Subscriber<T> {
@Nullable
private T value;
@Nullable
private Throwable error;
private final CountDownLatch latch = new CountDownLatch(1);
@Override
public void onSubscribe(Subscription subscription) {
subscription.request(1);
}
... |
try {
int timeout = 20;
if (!latch.await(timeout, TimeUnit.SECONDS)) {
this.error = new TimeoutException("Did not get response in " + timeout + " seconds.");
}
} catch (InterruptedException e) {
this.error = e;
}
| 239 | 83 | 322 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/mongo/shedlock-provider-mongo/src/main/java/net/javacrumbs/shedlock/provider/mongo/MongoLockProvider.java | MongoLockProvider | lock | class MongoLockProvider implements ExtensibleLockProvider {
static final String LOCK_UNTIL = "lockUntil";
static final String LOCKED_AT = "lockedAt";
static final String LOCKED_BY = "lockedBy";
static final String ID = "_id";
static final String DEFAULT_SHEDLOCK_COLLECTION_NAME = "shedLock";
pr... |
Instant now = now();
Bson update = combine(
set(LOCK_UNTIL, lockConfiguration.getLockAtMostUntil()), set(LOCKED_AT, now), set(LOCKED_BY, hostname));
try {
// There are three possible situations:
// 1. The lock document does not exist yet - it is inserted ... | 696 | 303 | 999 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/neo4j/shedlock-provider-neo4j/src/main/java/net/javacrumbs/shedlock/provider/neo4j/Neo4jStorageAccessor.java | Neo4jStorageAccessor | createLockNameUniqueConstraint | class Neo4jStorageAccessor extends AbstractStorageAccessor {
private final String collectionName;
private final Driver driver;
private final String databaseName;
public Neo4jStorageAccessor(@NonNull Driver driver, @NonNull String collectionName, @Nullable String databaseName) {
this.collectionN... |
try (Session session = getSession();
Transaction transaction = session.beginTransaction()) {
transaction.run(String.format(
"CREATE CONSTRAINT UNIQUE_%s_name IF NOT EXISTS FOR (lock:%s) REQUIRE lock.name IS UNIQUE",
collectionName, collectionN... | 1,346 | 89 | 1,435 | <methods>public non-sealed void <init>() <variables>protected final Logger logger |
lukas-krecan_ShedLock | ShedLock/providers/opensearch/shedlock-provider-opensearch/src/main/java/net/javacrumbs/shedlock/provider/opensearch/OpenSearchLockProvider.java | OpenSearchSimpleLock | doUnlock | class OpenSearchSimpleLock extends AbstractSimpleLock {
private OpenSearchSimpleLock(LockConfiguration lockConfiguration) {
super(lockConfiguration);
}
@Override
public void doUnlock() {<FILL_FUNCTION_BODY>}
} |
// Set lockUtil to now or lockAtLeastUntil whichever is later
try {
UpdateRequest ur = updateRequest(lockConfiguration)
.script(new Script(
ScriptType.INLINE,
"painless",
... | 65 | 154 | 219 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/r2dbc/shedlock-provider-r2dbc/src/main/java/net/javacrumbs/shedlock/provider/r2dbc/AbstractR2dbcStorageAccessor.java | AbstractR2dbcStorageAccessor | insertRecordReactive | class AbstractR2dbcStorageAccessor extends AbstractStorageAccessor {
private final String tableName;
public AbstractR2dbcStorageAccessor(@NonNull String tableName) {
this.tableName = requireNonNull(tableName, "tableName can not be null");
}
@Override
public boolean insertRecord(@NonNull Lo... |
// Try to insert if the record does not exist (not optimal, but the simplest
// platform agnostic
// way)
String sql = "INSERT INTO " + tableName + "(name, lock_until, locked_at, locked_by) VALUES("
+ toParameter(1, "name") + ", " + toParameter(2, "lock_until") + ", " + ... | 1,388 | 277 | 1,665 | <methods>public non-sealed void <init>() <variables>protected final Logger logger |
lukas-krecan_ShedLock | ShedLock/providers/r2dbc/shedlock-provider-r2dbc/src/main/java/net/javacrumbs/shedlock/provider/r2dbc/R2dbcAdapter.java | R2dbcAdapter | create | class R2dbcAdapter {
private static final String MSSQL_NAME = "Microsoft SQL Server";
private static final String MYSQL_NAME = "MySQL";
private static final String JASYNC_MYSQL_NAME = "Jasync-MySQL";
private static final String MARIA_NAME = "MariaDB";
private static final String ORACLE_NAME = "Oracl... |
return switch (driver) {
case MSSQL_NAME -> new DefaultR2dbcAdapter(
(index, name) -> "@" + name, R2dbcAdapter::toLocalDate, R2dbcAdapter::bindByName);
case MYSQL_NAME, JASYNC_MYSQL_NAME, MARIA_NAME -> new DefaultR2dbcAdapter(
(index, name) -> "?"... | 624 | 219 | 843 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/r2dbc/shedlock-provider-r2dbc/src/main/java/net/javacrumbs/shedlock/provider/r2dbc/R2dbcStorageAccessor.java | R2dbcStorageAccessor | executeCommand | class R2dbcStorageAccessor extends AbstractR2dbcStorageAccessor {
private final ConnectionFactory connectionFactory;
private R2dbcAdapter adapter;
R2dbcStorageAccessor(@NonNull ConnectionFactory connectionFactory, @NonNull String tableName) {
super(tableName);
this.connectionFactory = requ... |
return Mono.usingWhen(
Mono.from(connectionFactory.create()).doOnNext(it -> it.setAutoCommit(true)),
conn -> body.apply(conn.createStatement(sql))
.onErrorResume(throwable -> exceptionHandler.apply(sql, throwable)),
Connection::close,
... | 300 | 131 | 431 | <methods>public void <init>(java.lang.String) ,public boolean extend(net.javacrumbs.shedlock.core.LockConfiguration) ,public Publisher<java.lang.Boolean> extendReactive(net.javacrumbs.shedlock.core.LockConfiguration) ,public boolean insertRecord(net.javacrumbs.shedlock.core.LockConfiguration) ,public Publisher<java.lan... |
lukas-krecan_ShedLock | ShedLock/providers/redis/shedlock-provider-redis-jedis4/src/main/java/net/javacrumbs/shedlock/provider/redis/jedis4/JedisLockProvider.java | JedisLockProvider | lock | class JedisLockProvider implements ExtensibleLockProvider {
private static final String KEY_PREFIX = "job-lock";
private static final String ENV_DEFAULT = "default";
private final JedisTemplate jedisTemplate;
private final String environment;
public JedisLockProvider(@NonNull Pool<Jedis> jedisPoo... |
long expireTime = getMsUntil(lockConfiguration.getLockAtMostUntil());
String key = buildKey(lockConfiguration.getName(), this.environment);
String rez = jedisTemplate.set(key, buildValue(), setParams().nx().px(expireTime));
if ("OK".equals(rez)) {
return Optional.of(new R... | 1,330 | 114 | 1,444 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/redis/shedlock-provider-redis-quarkus2/src/main/java/net/javacrumbs/shedlock/provider/redis/quarkus/QuarkusRedisLockProvider.java | RedisLock | doUnlock | class RedisLock extends AbstractSimpleLock {
private final String key;
private final QuarkusRedisLockProvider quarkusLockProvider;
private RedisLock(String key, QuarkusRedisLockProvider jedisLockProvider, LockConfiguration lockConfiguration) {
super(lockConfiguration);
t... |
long keepLockFor = getMillisUntil(lockConfiguration.getLockAtLeastUntil());
// lock at least until is in the past
if (keepLockFor <= 0) {
try {
quarkusLockProvider.deleteKey(key);
} catch (Exception e) {
throw ... | 172 | 116 | 288 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/redis/shedlock-provider-redis-spring/src/main/java/net/javacrumbs/shedlock/provider/redis/spring/ReactiveRedisLockProvider.java | ReactiveRedisLock | doUnlock | class ReactiveRedisLock extends AbstractSimpleLock {
private final String key;
private final ReactiveStringRedisTemplate redisTemplate;
private static String createKey(String keyPrefix, String environment, String lockName) {
return String.format("%s:%s:%s", keyPrefix, environment, l... |
Instant now = ClockProvider.now();
Duration expirationTime = Duration.between(now, lockConfiguration.getLockAtLeastUntil());
if (expirationTime.isNegative() || expirationTime.isZero()) {
try {
redisTemplate.delete(key).block();
} c... | 214 | 153 | 367 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/redis/shedlock-provider-redis-spring/src/main/java/net/javacrumbs/shedlock/provider/redis/spring/RedisLockProvider.java | RedisLock | tryToSetExpiration | class RedisLock extends AbstractSimpleLock {
private final String key;
private final StringRedisTemplate redisTemplate;
private RedisLock(String key, StringRedisTemplate redisTemplate, LockConfiguration lockConfiguration) {
super(lockConfiguration);
this.key = key;
... |
return template.execute(
connection -> {
byte[] serializedKey = ((RedisSerializer<String>) template.getKeySerializer()).serialize(key);
byte[] serializedValue = ((RedisSerializer<String>) template.getValueSerializer())
.seriali... | 320 | 125 | 445 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/providers/spanner/shedlock-provider-spanner/src/main/java/net/javacrumbs/shedlock/provider/spanner/SpannerStorageAccessor.java | SpannerStorageAccessor | unlock | class SpannerStorageAccessor extends AbstractStorageAccessor {
private final String table;
private final String name;
private final String lockedBy;
private final String lockUntil;
private final String lockedAt;
private final String hostname;
private final DatabaseClient databaseClient;
... |
databaseClient.readWriteTransaction().run(tx -> {
findLock(tx, lockConfiguration.getName())
.filter(lock -> hostname.equals(lock.lockedBy()))
.ifPresent(lock -> tx.buffer(newUpdateBuilder(table)
.set(name)
... | 1,374 | 130 | 1,504 | <methods>public non-sealed void <init>() <variables>protected final Logger logger |
lukas-krecan_ShedLock | ShedLock/providers/zookeeper/shedlock-provider-zookeeper-curator/src/main/java/net/javacrumbs/shedlock/provider/zookeeper/curator/ZookeeperCuratorLockProvider.java | ZookeeperCuratorLockProvider | tryLock | class ZookeeperCuratorLockProvider implements LockProvider {
public static final String DEFAULT_PATH = "/shedlock";
private final String path;
private final CuratorFramework client;
private static final Logger logger = LoggerFactory.getLogger(ZookeeperCuratorLockProvider.class);
public ZookeeperCu... |
try {
client.setData()
.withVersion(stat.getVersion())
.forPath(nodePath, serialize(lockConfiguration.getLockAtMostUntil()));
return Optional.of(new CuratorLock(nodePath, client, lockConfiguration));
} catch (KeeperException.BadVersionExce... | 1,010 | 114 | 1,124 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/shedlock-core/src/main/java/net/javacrumbs/shedlock/core/AbstractSimpleLock.java | AbstractSimpleLock | extend | class AbstractSimpleLock implements SimpleLock {
private boolean valid = true;
protected final LockConfiguration lockConfiguration;
protected AbstractSimpleLock(LockConfiguration lockConfiguration) {
this.lockConfiguration = lockConfiguration;
}
@Override
public final void unlock() {
... |
checkValidity();
Optional<SimpleLock> result = doExtend(
new LockConfiguration(ClockProvider.now(), lockConfiguration.getName(), lockAtMostFor, lockAtLeastFor));
valid = false;
return result;
| 229 | 61 | 290 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/shedlock-core/src/main/java/net/javacrumbs/shedlock/core/DefaultLockManager.java | DefaultLockManager | executeWithLock | class DefaultLockManager implements LockManager {
private static final Logger logger = LoggerFactory.getLogger(DefaultLockManager.class);
private final LockingTaskExecutor lockingTaskExecutor;
private final LockConfigurationExtractor lockConfigurationExtractor;
public DefaultLockManager(LockProvider l... |
Optional<LockConfiguration> lockConfigOptional = lockConfigurationExtractor.getLockConfiguration(task);
if (lockConfigOptional.isEmpty()) {
logger.debug("No lock configuration for {}. Executing without lock.", task);
task.run();
} else {
lockingTaskExecutor.e... | 204 | 88 | 292 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/shedlock-core/src/main/java/net/javacrumbs/shedlock/core/DefaultLockingTaskExecutor.java | DefaultLockingTaskExecutor | executeWithLock | class DefaultLockingTaskExecutor implements LockingTaskExecutor {
private static final Logger logger = LoggerFactory.getLogger(DefaultLockingTaskExecutor.class);
private final LockProvider lockProvider;
public DefaultLockingTaskExecutor(LockProvider lockProvider) {
this.lockProvider = requireNonNul... |
String lockName = lockConfig.getName();
if (alreadyLockedBy(lockName)) {
logger.debug("Already locked '{}'", lockName);
return TaskResult.result(task.call());
}
Optional<SimpleLock> lock = lockProvider.lock(lockConfig);
if (lock.isPresent()) {
... | 285 | 420 | 705 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/shedlock-core/src/main/java/net/javacrumbs/shedlock/core/LockAssert.java | TestHelper | makeAllAssertsPass | class TestHelper {
private static final String TEST_LOCK_NAME = "net.javacrumbs.shedlock.core.test-lock";
/**
* If pass is set to true, all LockAssert.assertLocked calls in current thread
* will pass. To be used in unit tests only <code>
* LockAssert.TestHelper.makeAllAssert... |
if (pass) {
if (!LockAssert.alreadyLockedBy(TEST_LOCK_NAME)) {
LockAssert.startLock(TEST_LOCK_NAME);
}
} else {
if (LockAssert.alreadyLockedBy(TEST_LOCK_NAME)) {
LockAssert.endLock();
}
... | 135 | 84 | 219 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/shedlock-core/src/main/java/net/javacrumbs/shedlock/core/LockConfiguration.java | LockConfiguration | getUnlockTime | class LockConfiguration {
private final Instant createdAt;
private final String name;
/**
* The lock is held until this duration passes, after that it's automatically
* released (the process holding it has most likely died without releasing the
* lock) Can be ignored by providers which can ... |
Instant now = now();
Instant lockAtLeastUntil = getLockAtLeastUntil();
return lockAtLeastUntil.isAfter(now) ? lockAtLeastUntil : now;
| 723 | 51 | 774 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/shedlock-core/src/main/java/net/javacrumbs/shedlock/core/LockExtender.java | LockExtender | extendActiveLock | class LockExtender {
// Using deque here instead of a simple thread local to be able to handle nested
// locks.
private static final ThreadLocal<Deque<SimpleLock>> activeLocks = ThreadLocal.withInitial(LinkedList::new);
private LockExtender() {}
/**
* Extends active lock. Is based on a thread... |
SimpleLock lock = locks().peekLast();
if (lock == null) throw new NoActiveLockException();
Optional<SimpleLock> newLock = lock.extend(lockAtMostFor, lockAtLeastFor);
if (newLock.isPresent()) {
// removing and adding here should be safe as it's a thread local variable and
... | 511 | 140 | 651 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/shedlock-core/src/main/java/net/javacrumbs/shedlock/support/KeepAliveLockProvider.java | KeepAliveLock | extendForNextPeriod | class KeepAliveLock extends AbstractSimpleLock {
private final Duration lockExtensionPeriod;
private SimpleLock lock;
private Duration remainingLockAtLeastFor;
private final ScheduledFuture<?> future;
private boolean active = true;
private Instant currentLockAtMostUntil;
... |
// We can have a race-condition when we extend the lock but the `lock` field is
// accessed
// before we update it.
synchronized (this) {
if (!active) {
return;
}
if (currentLockAtMostUntil.isBefore(now(... | 395 | 339 | 734 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/shedlock-core/src/main/java/net/javacrumbs/shedlock/support/StorageBasedLockProvider.java | StorageBasedLockProvider | doLock | class StorageBasedLockProvider implements ExtensibleLockProvider {
private final StorageAccessor storageAccessor;
private final LockRecordRegistry lockRecordRegistry = new LockRecordRegistry();
protected StorageBasedLockProvider(StorageAccessor storageAccessor) {
this.storageAccessor = storageAcces... |
String name = lockConfiguration.getName();
boolean tryToCreateLockRecord = !lockRecordRegistry.lockRecordRecentlyCreated(name);
if (tryToCreateLockRecord) {
// create record in case it does not exist yet
if (storageAccessor.insertRecord(lockConfiguration)) {
... | 405 | 337 | 742 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/shedlock-core/src/main/java/net/javacrumbs/shedlock/support/Utils.java | Utils | initHostname | class Utils {
/**
* A {@link DateTimeFormatter} like {@link DateTimeFormatter#ISO_INSTANT} with
* the exception that it always appends exactly three fractional digits (nano
* seconds).
*
* <p>
* This is required in order to guarantee natural sorting, which enables us to
* use <cod... |
try {
return InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
return "unknown";
}
| 642 | 42 | 684 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/spring/shedlock-spring/src/main/java/net/javacrumbs/shedlock/spring/aop/AbstractLockConfiguration.java | AbstractLockConfiguration | setImportMetadata | class AbstractLockConfiguration implements ImportAware {
protected AnnotationAttributes annotationAttributes;
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {<FILL_FUNCTION_BODY>}
protected int getOrder() {
return annotationAttributes.getNumber("order");
}
} |
this.annotationAttributes = AnnotationAttributes.fromMap(
importMetadata.getAnnotationAttributes(EnableSchedulerLock.class.getName(), false));
if (this.annotationAttributes == null) {
throw new IllegalArgumentException(
"@EnableSchedulerLock is not presen... | 75 | 83 | 158 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/spring/shedlock-spring/src/main/java/net/javacrumbs/shedlock/spring/aop/MethodProxyLockConfiguration.java | MethodProxyLockConfiguration | proxyScheduledLockAopBeanPostProcessor | class MethodProxyLockConfiguration extends AbstractLockConfiguration {
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
MethodProxyScheduledLockAdvisor proxyScheduledLockAopBeanPostProcessor(
@Lazy LockProvider lockProvider, @Lazy ExtendedLockConfigurationExtractor lockConfigurationExtractor) {<F... |
MethodProxyScheduledLockAdvisor advisor = new MethodProxyScheduledLockAdvisor(
lockConfigurationExtractor, new DefaultLockingTaskExecutor(lockProvider));
advisor.setOrder(getOrder());
return advisor;
| 93 | 60 | 153 | <methods>public void setImportMetadata(AnnotationMetadata) <variables>protected AnnotationAttributes annotationAttributes |
lukas-krecan_ShedLock | ShedLock/spring/shedlock-spring/src/main/java/net/javacrumbs/shedlock/spring/aop/MethodProxyScheduledLockAdvisor.java | LockingInterceptor | invoke | class LockingInterceptor implements MethodInterceptor {
private final ExtendedLockConfigurationExtractor lockConfigurationExtractor;
private final LockingTaskExecutor lockingTaskExecutor;
LockingInterceptor(
ExtendedLockConfigurationExtractor lockConfigurationExtractor,
... |
Class<?> returnType = invocation.getMethod().getReturnType();
if (returnType.isPrimitive() && !void.class.equals(returnType)) {
throw new LockingNotSupportedException("Can not lock method returning primitive value");
}
LockConfiguration lockConfiguration... | 205 | 175 | 380 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/spring/shedlock-spring/src/main/java/net/javacrumbs/shedlock/spring/aop/RegisterDefaultTaskSchedulerPostProcessor.java | RegisterDefaultTaskSchedulerPostProcessor | postProcessBeanDefinitionRegistry | class RegisterDefaultTaskSchedulerPostProcessor
implements BeanDefinitionRegistryPostProcessor, Ordered, BeanFactoryAware {
private BeanFactory beanFactory;
private static final Logger logger = LoggerFactory.getLogger(RegisterDefaultTaskSchedulerPostProcessor.class);
@Override
public void post... |
ListableBeanFactory listableBeanFactory = (ListableBeanFactory) this.beanFactory;
if (BeanFactoryUtils.beanNamesForTypeIncludingAncestors(listableBeanFactory, TaskScheduler.class).length == 0) {
String[] scheduledExecutorsBeanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
... | 198 | 329 | 527 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/spring/shedlock-spring/src/main/java/net/javacrumbs/shedlock/spring/aop/SchedulerLockConfigurationSelector.java | SchedulerLockConfigurationSelector | selectImports | class SchedulerLockConfigurationSelector implements ImportSelector {
@Override
public String[] selectImports(AnnotationMetadata metadata) {<FILL_FUNCTION_BODY>}
} |
AnnotationAttributes attributes = AnnotationAttributes.fromMap(
metadata.getAnnotationAttributes(EnableSchedulerLock.class.getName(), false));
InterceptMode mode = attributes.getEnum("interceptMode");
if (mode == PROXY_METHOD) {
return new String[] {
... | 45 | 211 | 256 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/spring/shedlock-spring/src/main/java/net/javacrumbs/shedlock/spring/aop/SchedulerProxyLockConfiguration.java | SchedulerProxyLockConfiguration | proxyScheduledLockAopBeanPostProcessor | class SchedulerProxyLockConfiguration extends AbstractLockConfiguration {
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
SchedulerProxyScheduledLockAdvisor proxyScheduledLockAopBeanPostProcessor(
@Lazy LockProvider lockProvider, @Lazy ExtendedLockConfigurationExtractor lockConfigurationExtracto... |
SchedulerProxyScheduledLockAdvisor advisor = new SchedulerProxyScheduledLockAdvisor(
new DefaultLockManager(lockProvider, lockConfigurationExtractor));
advisor.setOrder(getOrder());
return advisor;
| 97 | 62 | 159 | <methods>public void setImportMetadata(AnnotationMetadata) <variables>protected AnnotationAttributes annotationAttributes |
lukas-krecan_ShedLock | ShedLock/spring/shedlock-spring/src/main/java/net/javacrumbs/shedlock/spring/aop/SchedulerProxyScheduledLockAdvisor.java | LockingInterceptor | invoke | class LockingInterceptor implements MethodInterceptor {
private final LockManager lockManager;
private LockingInterceptor(LockManager lockManager) {
this.lockManager = lockManager;
}
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {<FILL... |
Object[] arguments = invocation.getArguments();
if (arguments.length >= 1 && arguments[0] instanceof Runnable) {
arguments[0] = new LockableRunnable((Runnable) arguments[0], lockManager);
} else {
logger.warn("Task scheduler first argument should be R... | 88 | 94 | 182 | <no_super_class> |
lukas-krecan_ShedLock | ShedLock/spring/shedlock-spring/src/main/java/net/javacrumbs/shedlock/spring/aop/StringToDurationConverter.java | StringToDurationConverter | convert | class StringToDurationConverter implements Converter<String, Duration> {
static final StringToDurationConverter INSTANCE = new StringToDurationConverter();
private static final Pattern ISO8601 = Pattern.compile("^[\\+\\-]?P.*$");
private static final Pattern SIMPLE = Pattern.compile("^([\\+\\-]?\\d+)([a-... |
try {
if (ISO8601.matcher(source).matches()) {
return Duration.parse(source);
}
Matcher matcher = SIMPLE.matcher(source);
Assert.state(matcher.matches(), "'" + source + "' is not a valid duration");
long amount = Long.parseLong(matcher... | 388 | 158 | 546 | <no_super_class> |
RaiMan_SikuliX1 | SikuliX1/API/src/main/java/jxgrabkey/JXGrabKey.java | JXGrabKey | addHotkeyListener | class JXGrabKey {
private static final int SLEEP_WHILE_LISTEN_EXITS = 100;
private static boolean debug;
private static JXGrabKey instance;
private static Thread thread;
private static Vector<HotkeyListener> listeners = new Vector<HotkeyListener>();
/**
* This constructor starts a seper... |
if(listener == null){
throw new IllegalArgumentException("listener must not be null");
}
JXGrabKey.listeners.add(listener);
| 1,653 | 45 | 1,698 | <no_super_class> |
RaiMan_SikuliX1 | SikuliX1/API/src/main/java/jxgrabkey/X11MaskDefinitions.java | X11MaskDefinitions | awtMaskToX11Mask | class X11MaskDefinitions {
public static final int X11_SHIFT_MASK = 1 << 0;
public static final int X11_LOCK_MASK = 1 << 1;
public static final int X11_CONTROL_MASK = 1 << 2;
public static final int X11_MOD1_MASK = 1 << 3;
public static final int X11_MOD2_MASK = 1 << 4;
public static final int ... |
int x11Mask = 0;
if ((awtMask & InputEvent.SHIFT_MASK) != 0 || (awtMask & InputEvent.SHIFT_DOWN_MASK) != 0) {
x11Mask |= X11MaskDefinitions.X11_SHIFT_MASK;
}
if ((awtMask & InputEvent.ALT_MASK) != 0 || (awtMask & InputEvent.ALT_DOWN_MASK) != 0) {
x11Mask |= X11... | 263 | 381 | 644 | <no_super_class> |
RaiMan_SikuliX1 | SikuliX1/API/src/main/java/org/sikuli/basics/GenericHotkeyManager.java | GenericHotkeyManager | _removeHotkey | class GenericHotkeyManager extends HotkeyManager {
HotkeyController controller = null;
@Override
public boolean _addHotkey(int keyCode, int modifiers, HotkeyListener callback) {
if (controller == null) {
controller = HotkeyController.get();
}
return !controller.addHotkey(callback, keyCode, mod... |
if (controller == null) {
return false;
}
return controller.removeHotkey(keyCode, modifiers);
| 288 | 35 | 323 | <methods>public non-sealed void <init>() ,public abstract boolean _addHotkey(int, int, org.sikuli.basics.HotkeyListener) ,public abstract int _removeAll(Map<java.lang.String,java.lang.Integer[]>, boolean) ,public abstract boolean _removeHotkey(int, int) ,public boolean addHotkey(java.lang.String, org.sikuli.basics.Hotk... |
RaiMan_SikuliX1 | SikuliX1/API/src/main/java/org/sikuli/basics/HotkeyListener.java | HotkeyListener | invokeHotkeyPressed | class HotkeyListener {
/**
* Override this to implement your own hotkey handler.
*
* @param e HotkeyEvent
*/
abstract public void hotkeyPressed(HotkeyEvent e);
/**
* INTERNAL USE: system specific handler implementation
*
* @param e HotkeyEvent
*/
public void invokeHotkeyPressed(final H... |
Thread hotkeyThread = new Thread() {
@Override
public void run() {
hotkeyPressed(e);
}
};
hotkeyThread.start();
| 116 | 48 | 164 | <no_super_class> |
RaiMan_SikuliX1 | SikuliX1/API/src/main/java/org/sikuli/basics/LinuxHotkeyManager.java | MyHotkeyHandler | _addHotkey | class MyHotkeyHandler implements jxgrabkey.HotkeyListener {
public void onHotkey(int id) {
Debug.log(4, "Hotkey pressed");
HotkeyData data = _idCallbackMap.get(id);
HotkeyEvent e = new HotkeyEvent(data.key, data.modifiers);
data.listener.invokeHotkeyPressed(e);
}
}
;
private Map<... |
JXGrabKey grabKey = JXGrabKey.getInstance();
if (_gHotkeyId == 1) {
grabKey.addHotkeyListener(new MyHotkeyHandler());
}
_removeHotkey(keyCode, modifiers);
int id = _gHotkeyId++;
HotkeyData data = new HotkeyData(keyCode, modifiers, listener);
_idCallbackMap.put(id, data);
try {
... | 179 | 187 | 366 | <methods>public non-sealed void <init>() ,public abstract boolean _addHotkey(int, int, org.sikuli.basics.HotkeyListener) ,public abstract int _removeAll(Map<java.lang.String,java.lang.Integer[]>, boolean) ,public abstract boolean _removeHotkey(int, int) ,public boolean addHotkey(java.lang.String, org.sikuli.basics.Hotk... |
RaiMan_SikuliX1 | SikuliX1/API/src/main/java/org/sikuli/basics/Settings.java | Settings | setShowActions | class Settings {
public static boolean experimental = false;
public static boolean FindProfiling = false;
public static boolean InputFontMono = false;
public static int InputFontSize = 14;
//TODO Proxy as command line options
public static String proxyName = "";
public static String proxyIP = "";
pu... |
if (ShowActions) {
MoveMouseDelaySaved = MoveMouseDelay;
} else {
MoveMouseDelay = MoveMouseDelaySaved;
}
Settings.ShowActions = ShowActions;
| 1,523 | 53 | 1,576 | <no_super_class> |
RaiMan_SikuliX1 | SikuliX1/API/src/main/java/org/sikuli/guide/AnimationFactory.java | NewAnimator | actionPerformed | class NewAnimator implements ActionListener {
Timer timer;
boolean looping = false;
boolean animationRunning = false;
Visual sklComponent;
NewAnimator(Visual sklComponent) {
this.sklComponent = sklComponent;
}
protected void init() {
}
public void start() {
init();
timer = new Timer(25... |
if (isRunning()) {
Rectangle r = sklComponent.getBounds();
//setActualLocation((int) x, (int) y);
animate();
r.add(sklComponent.getBounds());
if (sklComponent.getTopLevelAncestor() != null) {
sklComponent.getTopLevelAncestor().repaint(r.x, r.y, r.width, r.height);
}... | 242 | 185 | 427 | <no_super_class> |
RaiMan_SikuliX1 | SikuliX1/API/src/main/java/org/sikuli/guide/Animator.java | CircleAnimatoOld | actionPerformed | class CircleAnimatoOld extends Animator{
int repeatCount;
int count;
LinearInterpolation funcr;
Point origin;
int radius;
public CircleAnimatoOld(Visual comp, int radius){
super(comp);
repeatCount = duration / cycle;
count = 0;
funcr = new LinearInterpolation(0,(float) (2*Math.PI),repea... |
float r = funcr.getValue(count);
int x = (int) (origin.x + (int) radius * Math.sin(r));
int y= (int) (origin.y + (int) radius * Math.cos(r));
Point p = new Point(x,y);
Rectangle r1 = comp.getBounds();
comp.setLocation(p);
// r1 stores the union of the bounds before/after the animated... | 165 | 232 | 397 | <methods>public void <init>(org.sikuli.guide.Visual) ,public boolean isPlayed() ,public boolean isRunning() ,public void start() ,public void stop() <variables>org.sikuli.guide.Visual comp,int cycle,int duration,boolean played,javax.swing.Timer timer |
RaiMan_SikuliX1 | SikuliX1/API/src/main/java/org/sikuli/guide/ClickableWindow.java | ClickableWindow | toFront | class ClickableWindow extends OverlayTransparentWindow
implements MouseListener, Transition, GlobalMouseMotionListener {
Guide guide;
JPanel jp = null;
ArrayList<SxClickable> clickables = new ArrayList<SxClickable>();
private SxClickable lastClicked;
private Rectangle maxR;
Point clickLocation;
G... |
// if (Settings.isMac()) {
// // this call is necessary to allow clicks to go through the window (ignoreMouse == true)
// if (Guide.JavaVersion < 7) {
// SysUtil.getOSUtil().bringWindowToFront(this, true);
// } else {
// }
// }
super.toFront();
| 1,249 | 94 | 1,343 | <methods>public void <init>() ,public void <init>(java.awt.Color, org.sikuli.util.EventObserver) ,public void addObserver(org.sikuli.util.EventObserver) ,public void close() ,public javax.swing.JPanel getJPanel() ,public java.awt.Graphics2D getJPanelGraphics() ,public void notifyObserver() ,public void setOpacity(float... |
RaiMan_SikuliX1 | SikuliX1/API/src/main/java/org/sikuli/guide/GlobalMouseMotionTracker.java | GlobalMouseMotionTracker | actionPerformed | class GlobalMouseMotionTracker implements ActionListener {
final static int IDLE_COUNT_THRESHOLD = 200;
// this keeps track of how many times the cursor stays stationary
int idle_count;
Location lastLocation = null;
static GlobalMouseMotionTracker _instance = null;
static public GlobalMouseMotionT... |
Location newLocation = Env.getMouseLocation();
//Debug.info("Mouse loction: " + newLocation);
if (lastLocation != null){
if (lastLocation.x != newLocation.x ||
lastLocation.y != newLocation.y){
for (GlobalMouseMotionListener listener : listeners){
... | 306 | 230 | 536 | <no_super_class> |
RaiMan_SikuliX1 | SikuliX1/API/src/main/java/org/sikuli/guide/HTMLTextPane.java | HTMLTextPane | setText | class HTMLTextPane extends JTextPane {
int maximum_width;
String text;
public Dimension preferredDimension;
Visual comp = null;
String htmltxt;
public HTMLTextPane(Visual comp) {
this.comp = comp;
maximum_width = comp.maxWidth - 10;
init();
}
public HTMLTextPane() {
maximum_width = 40... |
this.text = text;
if (comp != null) {
maximum_width = comp.maxWidth - 2 * comp.PADDING_X;
htmltxt = "<html><div style='" + comp.getStyleString() + "'>"
+ text + "</div></html>";
} else {
htmltxt = "<html><font size=5>"+text+"</font></html>";
}
super.setText(htmltxt);... | 188 | 308 | 496 | <methods>public void <init>() ,public void <init>(javax.swing.text.StyledDocument) ,public javax.swing.text.Style addStyle(java.lang.String, javax.swing.text.Style) ,public javax.swing.text.AttributeSet getCharacterAttributes() ,public javax.swing.text.MutableAttributeSet getInputAttributes() ,public javax.swing.text.S... |
RaiMan_SikuliX1 | SikuliX1/API/src/main/java/org/sikuli/guide/Run.java | Run | testButton | class Run {
Guide guide = null;
static Screen scr;
static Visual sgc;
public static void main(String[] args) throws FindFailed {
Run sgr = new Run();
sgr.scr = new Screen();
ImagePath.add("org.sikuli.script.RunTime/ImagesAPI.sikuli");
sgr.setUp();
sgr.testButton();
sgr.tearDown();
}
private void set... |
Debug.on(3);
Visual vis = guide.text("text");
// vis.setTarget(scr.getCenter().grow(100));
String img = "idea";
// Match match = scr.find(img);
// match.highlight(2);
vis.setTarget(img);
vis.setLayout(Visual.Layout.RIGHT);
vis.setTextColor(Color.red);
// g.setLocationRelativeToRegion(scr.getCe... | 202 | 177 | 379 | <no_super_class> |
RaiMan_SikuliX1 | SikuliX1/API/src/main/java/org/sikuli/guide/ShadowRenderer.java | ShadowRenderer | createShadowImage | class ShadowRenderer {
Visual source;
public ShadowRenderer(Visual source, int shadowSize){
this.source = source;
sourceActualSize = source.getActualSize();
this.shadowSize = shadowSize;
}
float shadowOpacity = 0.8f;
int shadowSize = 10;
Color shadowColor = Color.black;
Buffered... |
BufferedImage image = new BufferedImage(source.getActualWidth() + shadowSize * 2,
source.getActualHeight() + shadowSize * 2, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = image.createGraphics();
g2.translate(shadowSize,shadowSize);
source.paintPlain(g2);
shadowImage = new Bu... | 571 | 182 | 753 | <no_super_class> |
RaiMan_SikuliX1 | SikuliX1/API/src/main/java/org/sikuli/guide/SxAnchor.java | SxAnchor | startTracking | class SxAnchor extends Visual {
Region region;
ArrayList<AnchorListener> listeners = new ArrayList<AnchorListener>();
private boolean animateAnchoring = false;
Pattern pattern = null;
Tracker tracker = null;
public SxAnchor() {
super();
setForeground(Color.black);
}
public SxAnchor(Pattern pat... |
if (tracker != null) {
//Debug.info("[SxAnchor] start tracking");
tracker.start();
}
| 1,131 | 40 | 1,171 | <methods>public void <init>() ,public org.sikuli.guide.Visual above() ,public org.sikuli.guide.Visual above(int) ,public void addAnimation(org.sikuli.guide.NewAnimator) ,public void addAnimationListener(org.sikuli.guide.AnimationListener) ,public void addCircleAnimation(java.awt.Point, float) ,public void addFadeinAnim... |
RaiMan_SikuliX1 | SikuliX1/API/src/main/java/org/sikuli/guide/SxArea.java | SxArea | componentMoved | class SxArea extends Visual
implements ComponentListener{
ArrayList<Region> regions = new ArrayList<Region>();
ArrayList<Visual> landmarks = new ArrayList<Visual>();
public SxArea(){
super();
// default to transparent so it can be faded in when it becomes visible later
setOpacity(0);
}
... |
Rectangle r = getBounds();
updateBounds();
r.add(getBounds());
if (getTopLevelAncestor() != null)
getTopLevelAncestor().repaint(r.x,r.y,r.width,r.height);
| 1,063 | 72 | 1,135 | <methods>public void <init>() ,public org.sikuli.guide.Visual above() ,public org.sikuli.guide.Visual above(int) ,public void addAnimation(org.sikuli.guide.NewAnimator) ,public void addAnimationListener(org.sikuli.guide.AnimationListener) ,public void addCircleAnimation(java.awt.Point, float) ,public void addFadeinAnim... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.