use of org.jboss.as.ejb3.timerservice.TimerServiceImpl in project wildfly by wildfly.
the class FileTimerPersistence method loadActiveTimers.
@Override
public List<TimerImpl> loadActiveTimers(final String timedObjectId, final TimerServiceImpl timerService) {
final Lock lock = getLock(timedObjectId);
try {
lock.lock();
final Map<String, TimerImpl> timers = getTimers(timedObjectId, timerService);
final List<TimerImpl> entities = new ArrayList<TimerImpl>();
for (Map.Entry<String, TimerImpl> entry : timers.entrySet()) {
entities.add(mostRecentEntityVersion(entry.getValue()));
}
return entities;
} finally {
lock.unlock();
}
}
use of org.jboss.as.ejb3.timerservice.TimerServiceImpl in project wildfly by wildfly.
the class DatabaseTimerPersistence method timerFromResult.
private Holder timerFromResult(final ResultSet resultSet, final TimerServiceImpl timerService) throws SQLException {
boolean calendarTimer = resultSet.getBoolean(24);
final String nodeName = resultSet.getString(25);
boolean requiresReset = false;
TimerImpl.Builder builder = null;
if (calendarTimer) {
CalendarTimer.Builder cb = CalendarTimer.builder();
builder = cb;
//set calendar timer specifics first
cb.setScheduleExprSecond(resultSet.getString(10));
cb.setScheduleExprMinute(resultSet.getString(11));
cb.setScheduleExprHour(resultSet.getString(12));
cb.setScheduleExprDayOfWeek(resultSet.getString(13));
cb.setScheduleExprDayOfMonth(resultSet.getString(14));
cb.setScheduleExprMonth(resultSet.getString(15));
cb.setScheduleExprYear(resultSet.getString(16));
cb.setScheduleExprStartDate(resultSet.getTimestamp(17));
cb.setScheduleExprEndDate(resultSet.getTimestamp(18));
cb.setScheduleExprTimezone(resultSet.getString(19));
cb.setAutoTimer(resultSet.getBoolean(20));
final String clazz = resultSet.getString(21);
final String methodName = resultSet.getString(22);
if (methodName != null) {
final String paramString = resultSet.getString(23);
final String[] params = paramString == null || paramString.isEmpty() ? new String[0] : paramString.split(";");
final Method timeoutMethod = CalendarTimer.getTimeoutMethod(new TimeoutMethod(clazz, methodName, params), timerService.getTimedObjectInvoker().getValue().getClassLoader());
if (timeoutMethod == null) {
EjbLogger.EJB3_TIMER_LOGGER.timerReinstatementFailed(resultSet.getString(2), resultSet.getString(1), new NoSuchMethodException());
return null;
}
cb.setTimeoutMethod(timeoutMethod);
}
} else {
builder = TimerImpl.builder();
}
builder.setId(resultSet.getString(1));
builder.setTimedObjectId(resultSet.getString(2));
builder.setInitialDate(resultSet.getTimestamp(3));
builder.setRepeatInterval(resultSet.getLong(4));
builder.setNextDate(resultSet.getTimestamp(5));
builder.setPreviousRun(resultSet.getTimestamp(6));
builder.setPrimaryKey(deSerialize(resultSet.getString(7)));
builder.setInfo((Serializable) deSerialize(resultSet.getString(8)));
builder.setTimerState(TimerState.valueOf(resultSet.getString(9)));
builder.setPersistent(true);
TimerImpl ret = builder.build(timerService);
if (nodeName != null && (nodeName.equals(this.nodeName))) {
if (ret.getState() == TimerState.IN_TIMEOUT || ret.getState() == TimerState.RETRY_TIMEOUT) {
requiresReset = true;
}
}
return new Holder(ret, requiresReset);
}
Aggregations