Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
699 B
2
Indexable
Never
    public LockableTaskScheduler getLockableTaskScheduler() {
        final LockConfigurationExtractor lockConfigurationExtractor = task -> Optional.of(
            new LockConfiguration(
                Instant.now(),
                "taskName",
                Duration.ofSeconds(5),
                Duration.ofSeconds(5)));

        final var lockManager = new DefaultLockManager(lockProvider,
            lockConfigurationExtractor);
        final var threadPoolTaskScheduler = (ThreadPoolTaskScheduler) taskScheduler;
        threadPoolTaskScheduler.shutdown();
        threadPoolTaskScheduler.initialize();

        return new LockableTaskScheduler(threadPoolTaskScheduler, lockManager);
    }