I have got a Spring application that uses
@SpringBootApplication
and
@EnableScheduling
in the main java. Also it has a class with several @Scheduled methods:
@Component
public class ScheduledTasks {
(...)
@Scheduled(cron = "0 0/5 10-18 ? * *")
public void doThings() {
(...)
}
@Scheduled(cron = "0 0/22 23 ? * *")
public void doAnotherThings() {
(...)
}
As far as I know it does not declare any special Pool of Threads, ThreadPoolExecutor or things like that. The app works ok and the scheduled jobs run ok.
I would like to get the values of the @Scheduled anotation at runTime, just to know when the cron was defined and show the info to the user.
It is NOT necesary to change or add new task/jobs to the scheduler.
I have been trying some ideas in thi answer How are Spring <task:scheduled> objects represented at runtime? trying to get a autowired ThreadPoolExecutor or ThreadPoolTaskExecutor and then trying to see if a field of that object has usefull info but geting them with Autowired always fails when the application starts.
My app also says when starting "No TaskScheduler/ScheduledExecutorService bean found for scheduled processing", so I suppose it is using a default/easy way to run the scheduled methods, they work ok.
I dont know if it necesary to manually create a @Bean with that object in a @Configuration class to instrospect it, or how to fill the constructor asociated with them.
What object has the info asociated with the schedule jobs?
Can I autowire it in my own class to get the info?
Is it necesary to manually create it using @Bean in Spring ? How?
Thanks a lot.
application.properties? - Ken Bekov