@Test public void testOnApplicationEventMonitoredFileModified() throws IOException { expect(mockedSpringContextHolder.getBeanByNameIncludingChildContexts("scheduledBillingQueuePurger", AcmSchedulableBean.class)) .andReturn(mockedSchedulableBean); replay(mockedSpringContextHolder); AbstractConfigurationFileEvent event = new ConfigurationFileChangedEvent(mockedSource); event.setConfigFile(schedulerConfiguration); acmScheduler.onApplicationEvent(event); String configurationPath = Whitebox.getInternalState(acmScheduler, "configurationPath"); Map<String, AcmSchedulerTask> tasks = Whitebox.getInternalState(acmScheduler, "tasks"); assertTrue(configurationPath.endsWith("scheduledTasks.json")); assertTrue(tasks.containsKey("test")); AcmSchedulerTask task = tasks.get("test"); AcmSchedulableBean scheduledBean = Whitebox.getInternalState(task, "schedulableBean"); assertEquals(mockedSchedulableBean, scheduledBean); }
@Override public void onApplicationEvent(AbstractConfigurationFileEvent event) { if (isConfigurationFileChange(event)) { File configFile = event.getConfigFile(); try { synchronized (this) { FileTime lastModified = getConfigLastModifiedTime(configFile); if (lastModifiedTime == lastModified.toMillis()) { return; } log.debug("{} confgiration file {} has changed, updating state.", AcmScheduler.class.getName(), SCHEDULED_TASKS_CONFIGUTATION_FILENAME); processSchedulerConfiguration(configFile); } } catch (IOException | JSONException e) { log.error("Could not load scheduler configuration from file {}, error was: {}.", configFile.getAbsoluteFile(), e); } } }
AcmScheduler implements ApplicationListener<AbstractConfigurationFileEvent> { @Override public void onApplicationEvent(AbstractConfigurationFileEvent event) { if (isConfigurationFileChange(event)) { File configFile = event.getConfigFile(); try { synchronized (this) { FileTime lastModified = getConfigLastModifiedTime(configFile); if (lastModifiedTime == lastModified.toMillis()) { return; } log.debug("{} confgiration file {} has changed, updating state.", AcmScheduler.class.getName(), SCHEDULED_TASKS_CONFIGUTATION_FILENAME); processSchedulerConfiguration(configFile); } } catch (IOException | JSONException e) { log.error("Could not load scheduler configuration from file {}, error was: {}.", configFile.getAbsoluteFile(), e); } } } }
AcmScheduler implements ApplicationListener<AbstractConfigurationFileEvent> { @Override public void onApplicationEvent(AbstractConfigurationFileEvent event) { if (isConfigurationFileChange(event)) { File configFile = event.getConfigFile(); try { synchronized (this) { FileTime lastModified = getConfigLastModifiedTime(configFile); if (lastModifiedTime == lastModified.toMillis()) { return; } log.debug("{} confgiration file {} has changed, updating state.", AcmScheduler.class.getName(), SCHEDULED_TASKS_CONFIGUTATION_FILENAME); processSchedulerConfiguration(configFile); } } catch (IOException | JSONException e) { log.error("Could not load scheduler configuration from file {}, error was: {}.", configFile.getAbsoluteFile(), e); } } } AcmScheduler(TaskScheduler taskScheduler, TaskExecutor taskExecutor, SpringContextHolder springContextHolder); }
AcmScheduler implements ApplicationListener<AbstractConfigurationFileEvent> { @Override public void onApplicationEvent(AbstractConfigurationFileEvent event) { if (isConfigurationFileChange(event)) { File configFile = event.getConfigFile(); try { synchronized (this) { FileTime lastModified = getConfigLastModifiedTime(configFile); if (lastModifiedTime == lastModified.toMillis()) { return; } log.debug("{} confgiration file {} has changed, updating state.", AcmScheduler.class.getName(), SCHEDULED_TASKS_CONFIGUTATION_FILENAME); processSchedulerConfiguration(configFile); } } catch (IOException | JSONException e) { log.error("Could not load scheduler configuration from file {}, error was: {}.", configFile.getAbsoluteFile(), e); } } } AcmScheduler(TaskScheduler taskScheduler, TaskExecutor taskExecutor, SpringContextHolder springContextHolder); @Override void onApplicationEvent(AbstractConfigurationFileEvent event); void updateConfiguration(); }
AcmScheduler implements ApplicationListener<AbstractConfigurationFileEvent> { @Override public void onApplicationEvent(AbstractConfigurationFileEvent event) { if (isConfigurationFileChange(event)) { File configFile = event.getConfigFile(); try { synchronized (this) { FileTime lastModified = getConfigLastModifiedTime(configFile); if (lastModifiedTime == lastModified.toMillis()) { return; } log.debug("{} confgiration file {} has changed, updating state.", AcmScheduler.class.getName(), SCHEDULED_TASKS_CONFIGUTATION_FILENAME); processSchedulerConfiguration(configFile); } } catch (IOException | JSONException e) { log.error("Could not load scheduler configuration from file {}, error was: {}.", configFile.getAbsoluteFile(), e); } } } AcmScheduler(TaskScheduler taskScheduler, TaskExecutor taskExecutor, SpringContextHolder springContextHolder); @Override void onApplicationEvent(AbstractConfigurationFileEvent event); void updateConfiguration();  }