distributed-lock
distributed-lock copied to clipboard
Use Spring scheduler if enabled instead of overriding
Spring creates its own TaskScheduler bean if @EnableScheduler
is used. This library overrides Spring's TaskSchduler because it uses the same name/type and therefore Spring's bean is not used. This is the easiest way to deal with it, the only downside is that if people use @Scheduled
without @EnableScheduler
it will still work with this libary's TaskScheduler. The other is that you might want to use a dedicated TaskScheduler for refreshing. For the latter you could always override the LockBeanPostProcessor. I guess that would be applicable for such an advanced use case.
Alternatives:
- Use dedicated task scheduler with a different bean name, so it is easy extendable (downside, you cannot use Spring's one easily)