use of org.springframework.integration.file.DirectoryScanner in project spring-integration by spring-projects.
the class AbstractInboundFileSynchronizingMessageSource method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
super.afterPropertiesSet();
Assert.notNull(this.localDirectory, "localDirectory must not be null");
try {
if (!this.localDirectory.exists()) {
if (this.autoCreateLocalDirectory) {
if (logger.isDebugEnabled()) {
logger.debug("The '" + this.localDirectory + "' directory doesn't exist; Will create.");
}
this.localDirectory.mkdirs();
} else {
throw new FileNotFoundException(this.localDirectory.getName());
}
}
this.fileSource.setDirectory(this.localDirectory);
if (this.localFileListFilter == null) {
this.localFileListFilter = new FileSystemPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), getComponentName());
}
FileListFilter<File> filter = buildFilter();
if (this.scannerExplicitlySet) {
Assert.state(!this.fileSource.isUseWatchService(), "'useWatchService' and 'scanner' are mutually exclusive.");
this.fileSource.getScanner().setFilter(filter);
} else if (!this.fileSource.isUseWatchService()) {
DirectoryScanner directoryScanner = new DefaultDirectoryScanner();
directoryScanner.setFilter(filter);
this.fileSource.setScanner(directoryScanner);
} else {
this.fileSource.setFilter(filter);
}
if (this.getBeanFactory() != null) {
this.fileSource.setBeanFactory(this.getBeanFactory());
}
this.fileSource.afterPropertiesSet();
this.synchronizer.afterPropertiesSet();
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new BeanInitializationException("Failure during initialization of MessageSource for: " + this.getClass(), e);
}
}
Aggregations