Search in sources :

Example 31 with TimerConfig

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();
}
Also used : Timer(javax.ejb.Timer) TimerConfig(javax.ejb.TimerConfig) InitialContext(javax.naming.InitialContext) Date(java.util.Date) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 32 with TimerConfig

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);
}
Also used : TimerConfig(javax.ejb.TimerConfig) Date(java.util.Date)

Example 33 with TimerConfig

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));
}
Also used : ScheduleExpression(javax.ejb.ScheduleExpression) TimerConfig(javax.ejb.TimerConfig)

Example 34 with TimerConfig

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));
}
Also used : ScheduleExpression(javax.ejb.ScheduleExpression) TimerConfig(javax.ejb.TimerConfig)

Example 35 with TimerConfig

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));
    }
}
Also used : ScheduleExpression(javax.ejb.ScheduleExpression) DeploymentStore(org.jbpm.kie.services.impl.store.DeploymentStore) TimerConfig(javax.ejb.TimerConfig) PostConstruct(javax.annotation.PostConstruct)

Aggregations

TimerConfig (javax.ejb.TimerConfig)37 ScheduleExpression (javax.ejb.ScheduleExpression)13 Date (java.util.Date)8 PostConstruct (javax.annotation.PostConstruct)7 Test (org.junit.Test)7 Timer (javax.ejb.Timer)6 InitialContext (javax.naming.InitialContext)6 ModelNode (org.jboss.dmr.ModelNode)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 InSequence (org.jboss.arquillian.junit.InSequence)2 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 Serializable (java.io.Serializable)1 Method (java.lang.reflect.Method)1 Calendar (java.util.Calendar)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1