public void validate() { if (this.jobListenerType == null) { this.throwExceptionAndLogError("jobListenerType must not be null"); } if (this.pollerPeriod == null) { this.throwExceptionAndLogError("pollerPeriod must not be null"); } if (JobListenerType.LOCAL_FOLDER_LISTENER.equals(this.jobListenerType)) { this.validateLocalFolderListener(); } }
public static JobListenerConfiguration map(final Map<String, Object> values) { final JobListenerConfiguration jobListenerConfiguration = new JobListenerConfiguration(); jobListenerConfiguration.setBeanName(getValueOrNull(values, JobListenerConfigurationKey.BEAN_NAME, String.class)); jobListenerConfiguration.setFilePattern(getValueOrNull(values, JobListenerConfigurationKey.FILE_PATTERN, String.class)); jobListenerConfiguration.setPollerPeriod(getValueOrNull(values, JobListenerConfigurationKey.POLLER_PERIOD, Long.class)); jobListenerConfiguration.setSourceFolder(getValueOrNull(values, JobListenerConfigurationKey.SOURCE_FOLDER, String.class)); final ListenerStatus listenerStatus = ListenerStatus.getByValue(getValueOrNull(values, JobListenerConfigurationKey.STATUS, String.class)); jobListenerConfiguration.setListenerStatus(listenerStatus); final JobListenerType jobListenerType = JobListenerType.getById(getValueOrNull(values, JobListenerConfigurationKey.LISTENER_TYPE, Long.class)); jobListenerConfiguration.setJobListenerType(jobListenerType); final TaskExecutorType taskExecutorType = TaskExecutorType.getById(getValueOrNull(values, JobSchedulerConfigurationKey.TASK_EXECUTOR_TYPE, Long.class)); jobListenerConfiguration.setTaskExecutorType(taskExecutorType); return jobListenerConfiguration; }
private void validateCommon() { if (this.jobName == null) { this.throwExceptionAndLogError("jobName must not be null"); } if (this.jobSchedulerConfiguration == null) { if (this.jobListenerConfiguration == null) { this.throwExceptionAndLogError("jobSchedulerConfiguration or jobListenerConfiguration must not be null"); } else { this.getJobListenerConfiguration().validate(); } } else { this.jobSchedulerConfiguration.validate(); } }
public static JobSchedulerConfiguration map(final Map<String, Object> values) { final JobSchedulerConfiguration jobSchedulerConfiguration = new JobSchedulerConfiguration(); jobSchedulerConfiguration.setBeanName(getValueOrNull(values, JobSchedulerConfigurationKey.BEAN_NAME, String.class)); final JobSchedulerType jobSchedulerType = JobSchedulerType.getById(getValueOrNull(values, JobSchedulerConfigurationKey.SCHEDULER_TYPE, Long.class)); if (JobSchedulerType.CRON == jobSchedulerType) { jobSchedulerConfiguration.setCronExpression(getValueOrNull(values, JobSchedulerConfigurationKey.CRON_EXPRESSION, String.class)); } else if (JobSchedulerType.PERIOD == jobSchedulerType) { jobSchedulerConfiguration.setFixedDelay(getValueOrNull(values, JobSchedulerConfigurationKey.FIXED_DELAY, Long.class)); jobSchedulerConfiguration.setInitialDelay(getValueOrNull(values, JobSchedulerConfigurationKey.INITIAL_DELAY, Long.class)); } jobSchedulerConfiguration.setJobSchedulerType(jobSchedulerType); final SchedulerStatus schedulerStatus = SchedulerStatus.getByValue(getValueOrNull(values, JobSchedulerConfigurationKey.STATUS, String.class)); jobSchedulerConfiguration.setSchedulerStatus(schedulerStatus); final TaskExecutorType taskExecutorType = TaskExecutorType.getById(getValueOrNull(values, JobSchedulerConfigurationKey.TASK_EXECUTOR_TYPE, Long.class)); jobSchedulerConfiguration.setTaskExecutorType(taskExecutorType); return jobSchedulerConfiguration; }
public static JobSchedulerConfiguration createJobSchedulerConfiguration(final String cronExpression, final Long fixedDelay, final Long initialDelay, final JobSchedulerType jobSchedulerType) { final JobSchedulerConfiguration jobSchedulerConfiguration = new JobSchedulerConfiguration(); jobSchedulerConfiguration.setCronExpression(cronExpression); jobSchedulerConfiguration.setFixedDelay(fixedDelay); jobSchedulerConfiguration.setInitialDelay(initialDelay); jobSchedulerConfiguration.setJobSchedulerType(jobSchedulerType); jobSchedulerConfiguration.setTaskExecutorType(TaskExecutorType.SYNCHRONOUS); jobSchedulerConfiguration.setSchedulerStatus(SchedulerStatus.INITIALIZED); return jobSchedulerConfiguration; }
public static JobListenerConfiguration createJobListenerConfiguration(final String sourceFolder, final String pattern, final JobListenerType jobListenerType) { final JobListenerConfiguration jobListenerConfiguration = new JobListenerConfiguration(); jobListenerConfiguration.setJobListenerType(jobListenerType); jobListenerConfiguration.setTaskExecutorType(TaskExecutorType.SYNCHRONOUS); jobListenerConfiguration.setSourceFolder(sourceFolder); jobListenerConfiguration.setFilePattern(pattern); jobListenerConfiguration.setPollerPeriod(1000L); jobListenerConfiguration.setListenerStatus(ListenerStatus.STOPPED); return jobListenerConfiguration; } }
@Override public JobConfiguration mapRow(final ResultSet resultSet, final int rowNum) throws SQLException { final JobConfiguration jobConfiguration = new JobConfiguration(); jobConfiguration.setJobConfigurationId(resultSet.getLong(JobConfigurationDomain.JOB_CONFIGURATION_ID)); jobConfiguration.setJobName(resultSet.getString(JobConfigurationDomain.JOB_NAME)); final JobIncrementer jobIncrementer = JobIncrementer.getByIdentifier(resultSet .getString(JobConfigurationDomain.JOB_INCREMENTER)); jobConfiguration.setJobIncrementer(jobIncrementer); return jobConfiguration; } }
private void attachSchedulerStatus(final JobConfiguration jobConfiguration) { if (jobConfiguration.getJobSchedulerConfiguration() != null) { final String schedulerName = jobConfiguration.getJobSchedulerConfiguration().getBeanName(); final SchedulerStatus schedulerStatus = this.schedulerService.getSchedulerStatus(schedulerName); jobConfiguration.getJobSchedulerConfiguration().setSchedulerStatus(schedulerStatus); } } }
@Override public void refreshListenerForJob(final JobConfiguration jobConfiguration) { this.unregisterListenerForJob(jobConfiguration.getJobListenerConfiguration().getBeanName()); final String beanName = this.registerListenerForJob(jobConfiguration); final Listener listener = this.applicationContext.getBean(beanName, Listener.class); if (ListenerStatus.ACTIVE.equals(listener.getListenerStatus())) { listener.start(); } }
@Override public void refreshSchedulerForJob(final JobConfiguration jobConfiguration) { this.terminate(jobConfiguration.getJobSchedulerConfiguration().getBeanName()); this.unregisterSchedulerForJob(jobConfiguration.getJobSchedulerConfiguration().getBeanName()); this.registerSchedulerForJob(jobConfiguration); }
void validate() { if (this.jobSchedulerType == null) { this.throwExceptionAndLogError("jobSchedulerType must not be null"); } if (this.taskExecutorType == null) { this.throwExceptionAndLogError("taskExecutorType must not be null"); } if (JobSchedulerType.CRON.equals(this.jobSchedulerType)) { this.validateCron(); } else if (JobSchedulerType.PERIOD.equals(this.jobSchedulerType)) { this.validatePeriod(); } else { this.throwExceptionAndLogError("Unknown jobSchedulerType: " + this.jobSchedulerType); } }
public void validateForSave() { if (this.jobConfigurationId != null) { this.throwExceptionAndLogError("jobConfigurationId must not be set for save"); } this.validateCommon(); }
private String generateSchedulerBeanName(final String jobName, final Long id, final JobListenerType listenerType) { return jobName + listenerType.name() + id; }
private String generateSchedulerBeanName(final String jobName, final Long id, final JobSchedulerType jobSchedulerType) { return jobName + jobSchedulerType.name() + id; }
private void attachSchedulerStatus(final JobConfiguration jobConfiguration) { if (jobConfiguration.getJobSchedulerConfiguration() != null) { final String schedulerName = jobConfiguration.getJobSchedulerConfiguration().getBeanName(); final SchedulerStatus schedulerStatus = this.schedulerService.getSchedulerStatus(schedulerName); jobConfiguration.getJobSchedulerConfiguration().setSchedulerStatus(schedulerStatus); } } }
@Override public void refreshListenerForJob(final JobConfiguration jobConfiguration) { this.unregisterListenerForJob(jobConfiguration.getJobListenerConfiguration().getBeanName()); final String beanName = this.registerListenerForJob(jobConfiguration); final Listener listener = this.applicationContext.getBean(beanName, Listener.class); if (ListenerStatus.ACTIVE.equals(listener.getListenerStatus())) { listener.start(); } }
@Override public void refreshSchedulerForJob(final JobConfiguration jobConfiguration) { this.terminate(jobConfiguration.getJobSchedulerConfiguration().getBeanName()); this.unregisterSchedulerForJob(jobConfiguration.getJobSchedulerConfiguration().getBeanName()); this.registerSchedulerForJob(jobConfiguration); }
public void validateForUpdate() { if (this.jobConfigurationId == null) { this.throwExceptionAndLogError("jobConfigurationId must not be null for update"); } this.validateCommon(); }
private String generateSchedulerBeanName(final String jobName, final Long id, final JobListenerType listenerType) { return jobName + listenerType.name() + id; }
private String generateSchedulerBeanName(final String jobName, final Long id, final JobSchedulerType jobSchedulerType) { return jobName + jobSchedulerType.name() + id; }