I created an abstract class like this:
abstract class ScheduledProcess {
abstract List<String> fetchNewContent()
abstract List<String> cron()
//This SPeL doesn't work just stating what kind of expression I'm looking for
@Scheduled(cron='#{this.cron()}')
void persistContent(){
doSomeStuffWithContent(fetchNewContent())
}
}
My goal is to do not repeat myself having to implement the @Scheduled
method in all subclasses. The cron()
method returns the specific subclass cron expression. However I'm not finding a way to pass to the annotation the cron value. Maybe I'm just looking at this problem the wrong way.