use of javax.ejb.ScheduleExpression in project tomee by apache.
the class TimerServiceImpl method copy.
private ScheduleExpression copy(final ScheduleExpression scheduleExpression) {
final ScheduleExpression scheduleExpressionCopy = new ScheduleExpression();
scheduleExpressionCopy.year(scheduleExpression.getYear());
scheduleExpressionCopy.month(scheduleExpression.getMonth());
scheduleExpressionCopy.dayOfMonth(scheduleExpression.getDayOfMonth());
scheduleExpressionCopy.dayOfWeek(scheduleExpression.getDayOfWeek());
scheduleExpressionCopy.hour(scheduleExpression.getHour());
scheduleExpressionCopy.minute(scheduleExpression.getMinute());
scheduleExpressionCopy.second(scheduleExpression.getSecond());
scheduleExpressionCopy.start(scheduleExpression.getStart());
scheduleExpressionCopy.end(scheduleExpression.getEnd());
scheduleExpressionCopy.timezone(scheduleExpression.getTimezone());
return scheduleExpressionCopy;
}
use of javax.ejb.ScheduleExpression in project tomee by apache.
the class EJBCronTriggerPersistenceDelegate method loadExtendedTriggerProperties.
@Override
public TriggerPropertyBundle loadExtendedTriggerProperties(final Connection conn, final TriggerKey triggerKey) throws SQLException {
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = conn.prepareStatement(Util.rtp(SELECT_CRON_TRIGGER, tablePrefix, schedNameLiteral));
ps.setString(1, triggerKey.getName());
ps.setString(2, triggerKey.getGroup());
rs = ps.executeQuery();
if (rs.next()) {
final String cronExpr = rs.getString(COL_CRON_EXPRESSION);
final String timeZoneId = rs.getString(COL_TIME_ZONE_ID);
final String[] parts = cronExpr.split(EJBCronTrigger.DELIMITER);
try {
final EJBCronTrigger cb = new EJBCronTrigger(new ScheduleExpression().year(parts[0]).month(parts[1]).dayOfMonth(parts[2]).dayOfWeek(parts[3]).hour(parts[4]).minute(parts[5]).second(parts[6]).timezone(timeZoneId));
return new TriggerPropertyBundle(new EJBCronTriggerSceduleBuilder(cb), null, null);
} catch (final EJBCronTrigger.ParseException e) {
throw new IllegalStateException("Can't build the Trigger with key: '" + triggerKey + "' and statement: " + Util.rtp(SELECT_CRON_TRIGGER, tablePrefix, schedNameLiteral));
}
}
throw new IllegalStateException("No record found for selection of Trigger with key: '" + triggerKey + "' and statement: " + Util.rtp(SELECT_CRON_TRIGGER, tablePrefix, schedNameLiteral));
} finally {
Util.closeResultSet(rs);
Util.closeStatement(ps);
}
}
use of javax.ejb.ScheduleExpression in project tomee by apache.
the class CalendarTimerData method readObject.
private void readObject(final ObjectInputStream in) throws IOException {
super.doReadObject(in);
autoCreated = in.readBoolean();
try {
scheduleExpression = ScheduleExpression.class.cast(in.readObject());
} catch (final ClassNotFoundException e) {
throw new IOException(e);
}
}
use of javax.ejb.ScheduleExpression in project tomee by apache.
the class FarmerBrown method construct.
@PostConstruct
private void construct() {
final TimerConfig plantTheCorn = new TimerConfig("plantTheCorn", false);
timerService.createCalendarTimer(new ScheduleExpression().month(5).dayOfMonth("20-Last").minute(0).hour(8), plantTheCorn);
timerService.createCalendarTimer(new ScheduleExpression().month(6).dayOfMonth("1-10").minute(0).hour(8), plantTheCorn);
final TimerConfig harvestTheCorn = new TimerConfig("harvestTheCorn", false);
timerService.createCalendarTimer(new ScheduleExpression().month(9).dayOfMonth("20-Last").minute(0).hour(8), harvestTheCorn);
timerService.createCalendarTimer(new ScheduleExpression().month(10).dayOfMonth("1-10").minute(0).hour(8), harvestTheCorn);
final TimerConfig checkOnTheDaughters = new TimerConfig("checkOnTheDaughters", false);
timerService.createCalendarTimer(new ScheduleExpression().second("*").minute("*").hour("*"), checkOnTheDaughters);
}
use of javax.ejb.ScheduleExpression in project wildfly by wildfly.
the class TimerAttributeDefinition method addSchedule.
private static void addSchedule(Timer timer, ModelNode timerNode, final String componentName) {
try {
final ModelNode schedNode = timerNode.get(SCHEDULE);
ScheduleExpression sched = timer.getSchedule();
addScheduleDetailString(schedNode, sched.getYear(), YEAR);
addScheduleDetailString(schedNode, sched.getMonth(), MONTH);
addScheduleDetailString(schedNode, sched.getDayOfMonth(), DAY_OF_MONTH);
addScheduleDetailString(schedNode, sched.getDayOfWeek(), DAY_OF_WEEK);
addScheduleDetailString(schedNode, sched.getHour(), HOUR);
addScheduleDetailString(schedNode, sched.getMinute(), MINUTE);
addScheduleDetailString(schedNode, sched.getSecond(), SECOND);
addScheduleDetailString(schedNode, sched.getTimezone(), TIMEZONE);
addScheduleDetailDate(schedNode, sched.getStart(), START);
addScheduleDetailDate(schedNode, sched.getEnd(), END);
} catch (IllegalStateException e) {
// ignore
} catch (NoSuchObjectLocalException e) {
// ignore
} catch (EJBException e) {
logTimerFailure(componentName, e);
}
}
Aggregations