use of javax.ejb.TimerConfig in project wildfly by wildfly.
the class SimpleTimerServiceTestCase method testIntervalTimer.
@Test
@InSequence(3)
public void testIntervalTimer() throws NamingException {
InitialContext ctx = new InitialContext();
TimerConfig timerConfig = new TimerConfig();
timerConfig.setInfo(INFO_MSG_FOR_CHECK);
AnnotationTimerServiceBean bean1 = (AnnotationTimerServiceBean) ctx.lookup("java:module/" + AnnotationTimerServiceBean.class.getSimpleName());
bean1.resetTimerServiceCalled();
long ts = (new Date()).getTime() + TIMER_INIT_TIME_MS;
Timer timer1 = bean1.getTimerService().createIntervalTimer(new Date(ts), TIMER_TIMEOUT_TIME_MS, timerConfig);
Assert.assertTrue(AnnotationTimerServiceBean.awaitTimerCall());
bean1.resetTimerServiceCalled();
Assert.assertTrue(AnnotationTimerServiceBean.awaitTimerCall());
// verifies that timer1 equals itself and does not equal null
Assert.assertTrue(timer1.equals(timer1));
Assert.assertFalse(timer1.equals(null));
timer1.cancel();
TimedObjectTimerServiceBean bean2 = (TimedObjectTimerServiceBean) ctx.lookup("java:module/" + TimedObjectTimerServiceBean.class.getSimpleName());
bean2.resetTimerServiceCalled();
Timer timer2 = bean2.getTimerService().createIntervalTimer(TIMER_INIT_TIME_MS, TIMER_TIMEOUT_TIME_MS, timerConfig);
Assert.assertTrue(TimedObjectTimerServiceBean.awaitTimerCall());
bean2.resetTimerServiceCalled();
Assert.assertTrue(TimedObjectTimerServiceBean.awaitTimerCall());
timer2.cancel();
}
use of javax.ejb.TimerConfig in project wildfly by wildfly.
the class SimpleTimerBean method createTimerForNextDay.
public void createTimerForNextDay(final boolean persistent, final String info) {
this.timerService.createSingleActionTimer(new Date(System.currentTimeMillis() + (60 * 60 * 24 * 1000)), new TimerConfig(info, persistent));
logger.trace("Created a timer persistent = " + persistent + " info = " + info);
}
use of javax.ejb.TimerConfig in project eap-additional-testsuite by jboss-set.
the class SchedulerBean method initialize.
@Override
public void initialize(String info) {
ScheduleExpression sexpr = new ScheduleExpression();
// set schedule to every 10 seconds for demonstration
sexpr.hour("*").minute("*").second("0/10");
// persistent must be false because the timer is started by the HASingleton service
timerService.createCalendarTimer(sexpr, new TimerConfig(info, false));
}
use of javax.ejb.TimerConfig in project eap-additional-testsuite by jboss-set.
the class SchedulerBean2 method initialize.
@Override
public void initialize(String info) {
ScheduleExpression sexpr = new ScheduleExpression();
// set schedule to every 10 seconds for demonstration
sexpr.hour("*").minute("*").second("0/10");
// persistent must be false because the timer is started by the HASingleton service
timerService.createCalendarTimer(sexpr, new TimerConfig(info, false));
}
use of javax.ejb.TimerConfig in project jbpm by kiegroup.
the class DeploymentSynchronizerEJBImpl method configure.
@PostConstruct
public void configure() {
DeploymentStore store = new DeploymentStore();
store.setCommandService(commandService);
setDeploymentStore(store);
if (DEPLOY_SYNC_ENABLED) {
ScheduleExpression schedule = new ScheduleExpression();
schedule.hour("*");
schedule.minute("*");
schedule.second("*/" + DEPLOY_SYNC_INTERVAL);
timer = timerService.createCalendarTimer(schedule, new TimerConfig(null, false));
}
}
Aggregations