List of usage examples for javax.ejb ScheduleExpression ScheduleExpression
public ScheduleExpression()
From source file:eu.agilejava.snoop.scan.SnoopClient.java
public void register(final String clientId) { sendMessage(REGISTER_ENDPOINT, clientId); ScheduleExpression schedule = new ScheduleExpression(); schedule.second("*/10").minute("*").hour("*").start(Calendar.getInstance().getTime()); TimerConfig config = new TimerConfig(); config.setPersistent(false);//from ww w. ja va2 s.c om Timer timer = timerService.createCalendarTimer(schedule, config); LOGGER.config(() -> timer.getSchedule().toString()); }
From source file:eu.agilejava.snoop.eureka.scan.EurekaClient.java
@PostConstruct private void init() { LOGGER.config("Checking if snoop eureka is enabled"); LOGGER.config(() -> "YES: " + SnoopEurekaExtensionHelper.isEurekaEnabled()); if (SnoopEurekaExtensionHelper.isEurekaEnabled()) { readProperties();//from w w w .j a v a 2 s. co m EurekaConfig eurekaConfig = new EurekaConfig(); eurekaConfig.setHostName(applicationName); eurekaConfig.setApp(applicationName); eurekaConfig.setIpAddr("localhost"); eurekaConfig.setPort(8080); eurekaConfig.setStatus("UP"); eurekaConfig.setHomePageUrl(applicationHome); Entity<InstanceConfig> entity = Entity.entity(new InstanceConfig(eurekaConfig), MediaType.APPLICATION_JSON); Response response = ClientBuilder.newClient().target(serviceUrl + "apps/" + applicationName).request() .post(entity); LOGGER.config(() -> "POST resulted in: " + response.getStatus() + ", " + response.getEntity()); ScheduleExpression schedule = new ScheduleExpression(); schedule.second("*/10").minute("*").hour("*").start(Calendar.getInstance().getTime()); TimerConfig config = new TimerConfig(); config.setPersistent(false); Timer timer = timerService.createCalendarTimer(schedule, config); LOGGER.config(() -> timer.getSchedule().toString()); } else { LOGGER.config("Snoop Eureka is not enabled. Use @EnableEurekaClient!"); } }
From source file:eu.agilejava.snoop.scan.SnoopRegistrationClient.java
public void register(final String clientId) { sendMessage(REGISTER_ENDPOINT, applicationConfig.toJSON()); ScheduleExpression schedule = new ScheduleExpression(); schedule.second("*/10").minute("*").hour("*").start(Calendar.getInstance().getTime()); TimerConfig config = new TimerConfig(); config.setPersistent(false);// w ww . jav a 2s . c om Timer timer = timerService.createCalendarTimer(schedule, config); LOGGER.config(() -> timer.getSchedule().toString()); }
From source file:h2backup.BackupTimerService.java
@PostConstruct public void init() { if (!enabled) { log.info("H2 database backup is disabled"); return;// w w w.j a va 2s .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); }
From source file:be.fedict.eid.dss.model.bean.DocumentServiceBean.java
private ScheduleExpression getScheduleExpression(String cronSchedule) { ScheduleExpression schedule = new ScheduleExpression(); String[] fields = cronSchedule.split(" "); if (fields.length > 8) { throw new IllegalArgumentException("Too many fields in cronexpression: " + cronSchedule); }// ww w . j a v a 2s .c o m if (fields.length > 1) { schedule.second(fields[0]); } if (fields.length > 2) { schedule.minute(fields[1]); } if (fields.length > 3) { schedule.hour(fields[2]); } if (fields.length > 4) { schedule.dayOfMonth(fields[3]); } if (fields.length > 5) { schedule.month(fields[4]); } if (fields.length > 6) { schedule.dayOfWeek(fields[5]); } if (fields.length > 7) { schedule.year(fields[6]); } return schedule; }
From source file:com.hiperium.bo.control.impl.TaskBOImpl.java
/** * /*from w w w . ja v a 2s .c o m*/ * @param task * @throws InformationException */ @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) private void createCalendarTimer(Task task) throws InformationException { this.log.debug("createCalendarTimer - START"); ScheduleExpression expression = new ScheduleExpression(); // TODO: Create CRON TASK based on task.getCronTask() parameter. this.timerService.createCalendarTimer(expression, new TimerConfig(task.getId(), true)); this.log.debug("createCalendarTimer - END"); }
From source file:pl.psnc.synat.wrdz.mdz.config.MdzConfiguration.java
/** * Reads the schedule definition from the given configuration subset. Handles the hour, minute, day of week, day of * month, and month values./*from w w w .j av a 2 s. c o m*/ * * @param config * configuration subset * @return configured schedule object to be used with a timer */ private ScheduleExpression readSchedule(Configuration config) { ScheduleExpression expression = new ScheduleExpression(); if (config.containsKey(SCHEDULE_HOUR)) { expression.hour(config.getString(SCHEDULE_HOUR)); } if (config.containsKey(SCHEDULE_MINUTE)) { expression.minute(config.getString(SCHEDULE_MINUTE)); } if (config.containsKey(SCHEDULE_DAY_OF_WEEK)) { expression.dayOfWeek(config.getString(SCHEDULE_DAY_OF_WEEK)); } if (config.containsKey(SCHEDULE_DAY_OF_MONTH)) { expression.dayOfMonth(config.getString(SCHEDULE_DAY_OF_MONTH)); } if (config.containsKey(SCHEDULE_MONTH)) { expression.month(config.getString(SCHEDULE_MONTH)); } return expression; }
From source file:ru.simplgroupp.passportinfo.csv.CsvUtil.java
@PostConstruct public void initialize() { ScheduleExpression expression = new ScheduleExpression(); //expression.second("0").minute("16").hour("*"); expression.dayOfWeek(propsHolder.getDayOfWeek()).hour(propsHolder.getHour()).minute(propsHolder.getMinute()) .second(0);/*from w w w .j a v a2 s . co m*/ timer = timerService.createCalendarTimer(expression); log.info("Initialized"); }