java - Spring @Scheduled annotation -


how can use @scheduled annotation of spring dynamically?

crontrigger(string expression, timezone timezone) 

http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/scheduling/support/crontrigger.html#crontrigger-java.lang.string-java.util.timezone-

as have multiple timezones in database, how can pass them dynamically?

i tried in code:

timezone timezone = null; string timezone1 = null; public schedulerbean(string timezone2)  {      this.timezone1 = timezone2;   //constructor }  @scheduled(cron="0 0 8 * * ?", zone =timezone.gettimezone(timezone1) ) //error @ line public void sendquestionnotif()  {   //......code } 

here error getting,

*type mismatch: cannot convert timezone string* 

please me. because want trigger cron based on timezones. tia.

annotation parameters cannot set dynamically. can programmatically, this

class scheduler implements runnable {     public scheduler(taskscheduler scheduler, string timezone, string cron) {         scheduler.schedule(this, new crontrigger(cron, timezone.gettimezone(timezone)));     }      @override     public void run() {         //     } } 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -