Currently I am using following configuration to schedule my scheduler.
@Schedule(second ="1/10", minute = "*", hour = "*")
private void scheduleUser() {
try {
new UserFacade().insertUserInfo();
} catch (Exception e) {
logger.error("Error in : " + e);
}
}
Now I want to set timer value in run time not in hard coded way. Let say I have a bean call Property
and it has a field called frequency
.
Now I want to set values like new Property().getFrequency()
for EJB
scheduler.
Is there any way to do some thing like following?
@Schedule(second =new Property().getFrequency(), minute = "*", hour = "*")
private void scheduleUser() {
try {
new UserFacade().insertUserInfo();
} catch (Exception e) {
logger.error("Error in : " + e);
}
}
Not with annotations, no. You have to use programmatic timers (Java 7, EE7):
See https://docs.oracle.com/javaee/7/tutorial/ejb-basicexamples004.htm for further information.