use of javax.ejb.TimerConfig in project wildfly by wildfly.
the class RefreshBeanBase method createTimer.
/**
* {@inheritDoc}
*/
@Override
public byte[] createTimer(final long delay, final Serializable info) {
final Timer timer = timerService.createSingleActionTimer(delay, new TimerConfig(info, true));
if (info == Info.RETURN_HANDLE) {
final TimerHandle handle = timer.getHandle();
try (final ByteArrayOutputStream bos = new ByteArrayOutputStream();
final ObjectOutputStream out = new ObjectOutputStream(bos)) {
out.writeObject(handle);
out.flush();
return bos.toByteArray();
} catch (IOException e) {
throw new RuntimeException("Failed to serialize timer handle for timer: " + timer, e);
}
} else {
return null;
}
}
use of javax.ejb.TimerConfig in project tomee by apache.
the class MethodScheduleBuilder method addSchedulesToMethod.
private void addSchedulesToMethod(final MethodContext methodContext, final MethodScheduleInfo info) {
if (methodContext == null) {
return;
}
for (final ScheduleInfo scheduleInfo : info.schedules) {
final ScheduleExpression expr = new ScheduleExpression();
expr.second(scheduleInfo.second == null ? "0" : scheduleInfo.second);
expr.minute(scheduleInfo.minute == null ? "0" : scheduleInfo.minute);
expr.hour(scheduleInfo.hour == null ? "0" : scheduleInfo.hour);
expr.dayOfWeek(scheduleInfo.dayOfWeek == null ? "*" : scheduleInfo.dayOfWeek);
expr.dayOfMonth(scheduleInfo.dayOfMonth == null ? "*" : scheduleInfo.dayOfMonth);
expr.month(scheduleInfo.month == null ? "*" : scheduleInfo.month);
expr.year(scheduleInfo.year == null ? "*" : scheduleInfo.year);
expr.timezone(scheduleInfo.timezone);
expr.start(scheduleInfo.start);
expr.end(scheduleInfo.end);
final TimerConfig config = new TimerConfig();
config.setInfo(scheduleInfo.info);
config.setPersistent(scheduleInfo.persistent);
methodContext.getSchedules().add(new ScheduleData(config, expr));
}
}
use of javax.ejb.TimerConfig in project quickstart by wildfly.
the class SingletonTimer method initialize.
@PostConstruct
public void initialize() {
LOGGER.warning("SingletonTimer is initializing.");
// For the demonstration just output a Hello World log every 5 seconds.
ScheduleExpression scheduleExpression = new ScheduleExpression().hour("*").minute("*").second("0/5");
// Persistent must be set to false (since it defaults to true) because the timer is not specific to this JVM.
TimerConfig test = new TimerConfig("Hello World!", false);
timerService.createCalendarTimer(scheduleExpression, test);
}
use of javax.ejb.TimerConfig in project quickstart by wildfly.
the class TimeoutExample method initialize.
@PostConstruct
public void initialize() {
ScheduleExpression se = new ScheduleExpression();
// Set schedule to every 3 seconds (starting at second 0 of every minute).
se.hour("*").minute("*").second("0/3");
timerService.createCalendarTimer(se, new TimerConfig("EJB timer service timeout at ", false));
}
use of javax.ejb.TimerConfig in project wildfly by wildfly.
the class WaitTimeSingletonBean method startTimer.
private void startTimer() {
final TimerConfig timerConfig = new TimerConfig("WaitTimeSingletonBean timer " + timerNumbers.getAndIncrement(), false);
timerService.createSingleActionTimer(1, timerConfig);
}
Aggregations