int pollFrequency = scheduledListener.getPollFrequencySeconds();
int pollLatency = getPollLatencySeconds(scheduledListener);
if(scheduleIdRef != null) {
listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_ID_REF, scheduleIdRef);
final Schedule schedule = model.getSchedule(scheduleIdRef) ;
if (schedule.isSetStartDate()) {
listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_START_DATE, Long.toString(schedule.getStartDate().getTimeInMillis())) ;
}
if (schedule.isSetEndDate()) {
listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_END_DATE, Long.toString(schedule.getEndDate().getTimeInMillis())) ;
}
if (schedule instanceof SimpleSchedule) {
final SimpleSchedule simpleSchedule = (SimpleSchedule)schedule ;
final long simpleFrequency = simpleSchedule.getFrequency() ;
final FrequencyUnit.Enum unit = simpleSchedule.getFrequencyUnits() ;
final String frequencyVal ;
if (unit.equals(FrequencyUnit.SECONDS)) {
frequencyVal = Long.toString(simpleFrequency * 1000) ;
} else {
frequencyVal = Long.toString(simpleFrequency) ;
}
listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_SIMPLE_FREQUENCY, frequencyVal) ;
if (simpleSchedule.isSetExecCount()) {
listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_SIMPLE_EXEC, Integer.toString(simpleSchedule.getExecCount())) ;
}
} else if (schedule instanceof CronSchedule) {
final String cronExpression = ((CronSchedule)schedule).getCronExpression() ;
if (cronExpression == null) {
throw new ConfigurationException("Missing cron expression from configuration") ;
}
listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_CRON_EXPRESSION, cronExpression) ;
} else {
throw new ConfigurationException("Unknown schedule type specified in configuration: " + schedule.getClass().getName()) ;
}
if(domElement.hasAttribute("poll-frequency-seconds") || domElement.hasAttribute("schedule-frequency") ) {
logger.warn("Schedule Listener '" + listenerConfig.getTagName() + "' defines both 'scheduleidref' and frequency attributes. Using the 'scheduleidref'.");
}