use of org.jboss.as.ejb3.timerservice.TimerImpl in project wildfly by wildfly.
the class CalendarTimerTask method invokeBeanMethod.
@Override
protected void invokeBeanMethod(TimerImpl timer) throws Exception {
// finally invoke the timeout method through the invoker
if (timer.isAutoTimer()) {
CalendarTimer calendarTimer = (CalendarTimer) timer;
TimedObjectInvoker invoker = this.timerService.getInvoker();
// call the timeout method
invoker.callTimeout(calendarTimer, calendarTimer.getTimeoutMethod());
} else {
this.timerService.getInvoker().callTimeout(timer);
}
}
use of org.jboss.as.ejb3.timerservice.TimerImpl 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);
}
use of org.jboss.as.ejb3.timerservice.TimerImpl in project wildfly by wildfly.
the class TimerServiceImpl method getTimer.
/**
* Returns the timer corresponding to the passed timer id and timed object id.
*
* @param timerId timer id
* @param timedObjectId timed object id
* @return the {@code TimerImpl} corresponding to the passed timer id and timed object id
*/
public TimerImpl getTimer(final String timerId, final String timedObjectId) {
TimerImpl timer;
timer = this.timers.get(timerId);
if (timer != null) {
return timer;
}
timer = getWaitingOnTxCompletionTimers().get(timerId);
if (timer != null) {
return timer;
}
final TimerPersistence persistence = timerPersistence.getOptionalValue();
if (persistence instanceof DatabaseTimerPersistence) {
timer = ((DatabaseTimerPersistence) persistence).loadTimer(timedObjectId, timerId, this);
}
return timer;
}
use of org.jboss.as.ejb3.timerservice.TimerImpl in project wildfly by wildfly.
the class TimerAttributeDefinition method addInfo.
private static void addInfo(Timer timer, ModelNode timerNode, final String componentName) {
try {
final Serializable info = ((TimerImpl) timer).getCachedTimerInfo();
if (info != null) {
final ModelNode detailNode = timerNode.get(INFO);
detailNode.set(info.toString());
}
} catch (IllegalStateException e) {
// ignore
} catch (NoSuchObjectLocalException e) {
// ignore
} catch (EJBException e) {
logTimerFailure(componentName, e);
}
}
use of org.jboss.as.ejb3.timerservice.TimerImpl 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();
}
}
Aggregations