Hello What I want to achieve is have a scheduler setup so that it runs every X minutes, this x minutes should be read from a configuration file. I'm getting a compilation error saying "Attribute value must be a constant". Can you suggest me the best approach on a situation like this.
I have tried out few approaches.
using a constructor
@Singleton @LocalBean public class Scheduler { final String SCHEDULER; public Scheduler() { ConfigResources configResources = ConfigResources.getConfigResources(); SCHEDULER = configResources.getEolApiScheduler(); } @Schedule(minute= SCHEDULER, hour="*") public void retryEndOfLeaseSchedule() { System.out.println("inside retryEndOfLeaseSchedule "); }
using a static block
@Singleton @LocalBean public class Scheduler { final static String SCHEDULER; static { ConfigResources configResources = ConfigResources.getConfigResources(); SCHEDULER = configResources.getEolApiScheduler(); } @Schedule(minute= SCHEDULER, hour="*") public void retryEndOfLeaseSchedule() { System.out.println("inside retryEndOfLeaseSchedule "); }