List of usage examples for javax.ejb ScheduleExpression timezone
public ScheduleExpression timezone(String timezoneID)
From source file:h2backup.BackupTimerService.java
@PostConstruct public void init() { if (!enabled) { log.info("H2 database backup is disabled"); return;//from w w w . ja v a2s.co m } if (StringUtils.isEmpty(methodName)) { log.warn("No H2 database backup methods were specified"); return; } method = BackupMethod.valueOf(methodName); if (StringUtils.isEmpty(directory)) { directory = System.getProperty("user.dir"); } toList = asList(to.split(LIST_DELIMITER)); if (text == null) { text = StringUtils.EMPTY; } String timerInfoName = getTimerInfoName(); for (Timer timer : timerService.getAllTimers()) { if (timer.getInfo() instanceof BackupTimerInfo) { BackupTimerInfo timerInfo = (BackupTimerInfo) timer.getInfo(); if (StringUtils.equals(timerInfoName, timerInfo.getName())) { log.info("H2 database backup is already scheduled: {}", timerInfo); return; } } } ScheduleExpression scheduleExpression = new ScheduleExpression(); if (StringUtils.isNoneEmpty(year)) { scheduleExpression.year(year); } if (StringUtils.isNoneEmpty(month)) { scheduleExpression.month(month); } if (StringUtils.isNoneEmpty(dayOfMonth)) { scheduleExpression.dayOfMonth(dayOfMonth); } if (StringUtils.isNoneEmpty(dayOfWeek)) { scheduleExpression.dayOfWeek(dayOfWeek); } if (StringUtils.isNoneEmpty(hour)) { scheduleExpression.hour(hour); } if (StringUtils.isNoneEmpty(minute)) { scheduleExpression.minute(minute); } if (StringUtils.isNoneEmpty(second)) { scheduleExpression.second(second); } if (StringUtils.isNoneEmpty(timezone)) { scheduleExpression.timezone(timezone); } BackupTimerInfo timerInfo = new BackupTimerInfo(timerInfoName, scheduleExpression, Instant.now()); TimerConfig timerConfig = new TimerConfig(); timerConfig.setInfo(timerInfo); timerConfig.setPersistent(true); timerService.createCalendarTimer(scheduleExpression, timerConfig); log.info("Scheduled H2 database backup: {}", timerInfo); }