org.springframework.integration.file.filters.AcceptOnceFileListFilter Java Examples

The following examples show how to use org.springframework.integration.file.filters.AcceptOnceFileListFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SftpConfig.java    From java-examples with MIT License 5 votes vote down vote up
@Bean
@InboundChannelAdapter(channel = "fromSftpChannel", poller = @Poller(cron = "0/5 * * * * *"))
public MessageSource<File> sftpMessageSource() {
    SftpInboundFileSynchronizingMessageSource source = new SftpInboundFileSynchronizingMessageSource(
            sftpInboundFileSynchronizer());
    source.setLocalDirectory(new File(sftpLocalDirectoryDownload));
    source.setAutoCreateLocalDirectory(true);
    source.setLocalFilter(new AcceptOnceFileListFilter<File>());
    return source;
}
 
Example #2
Source File: GcsStreamingMessageSourceTests.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
@Bean
@InboundChannelAdapter(value = "unsortedChannel", poller = @Poller(fixedDelay = "100"))
public MessageSource<InputStream> unsortedChannelAdapter(Storage gcs) {
	GcsStreamingMessageSource adapter =
			new GcsStreamingMessageSource(new RemoteFileTemplate<>(new GcsSessionFactory(gcs)));
	adapter.setRemoteDirectory("gcsbucket");
	adapter.setFilter(new AcceptOnceFileListFilter<>());

	return adapter;
}
 
Example #3
Source File: GcsStreamingMessageSourceTests.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
@Bean
@InboundChannelAdapter(value = "sortedChannel", poller = @Poller(fixedDelay = "100"))
public MessageSource<InputStream> sortedChannelAdapter(Storage gcs) {
	GcsStreamingMessageSource adapter =
			new GcsStreamingMessageSource(
					new RemoteFileTemplate<>(new GcsSessionFactory(gcs)),
					Comparator.comparing(blob -> blob.getName()));

	adapter.setRemoteDirectory("gcsbucket");
	adapter.setFilter(new AcceptOnceFileListFilter<>());

	return adapter;
}
 
Example #4
Source File: GcsInboundFileSynchronizerTests.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
@Test
public void testCopyFiles() throws Exception {
	File localDirectory = new File("test");
	GcsInboundFileSynchronizer synchronizer = new GcsInboundFileSynchronizer(this.gcs);
	synchronizer.setRemoteDirectory("test-bucket");
	synchronizer.setBeanFactory(mock(BeanFactory.class));

	GcsInboundFileSynchronizingMessageSource adapter = new GcsInboundFileSynchronizingMessageSource(synchronizer);
	adapter.setAutoCreateLocalDirectory(true);
	adapter.setLocalDirectory(localDirectory);
	adapter.setBeanFactory(mock(BeanFactory.class));

	adapter.setLocalFilter(new AcceptOnceFileListFilter<>());

	adapter.afterPropertiesSet();

	Message<File> message = adapter.receive();
	assertThat(message.getPayload().getName()).isEqualTo("legend of heroes");
	assertThat(Files.readAllBytes(message.getPayload().toPath())).isEqualTo("estelle".getBytes());

	message = adapter.receive();
	assertThat(message.getPayload().getName()).isEqualTo("trails in the sky");
	assertThat(Files.readAllBytes(message.getPayload().toPath())).isEqualTo("joshua".getBytes());

	message = adapter.receive();
	assertThat(message).isNull();
}
 
Example #5
Source File: FolderListener.java    From spring-batch-lightmin with Apache License 2.0 5 votes vote down vote up
private void initFileListFilter() throws Exception {
    this.fileFileListFilter = new CompositeFileListFilter<>();
    this.fileFileListFilter.addFilter(new AcceptOnceFileListFilter<>());
    this.fileFileListFilter.addFilter(new IgnoreHiddenFileListFilter());

    this.fileFileListFilter.addFilter(new SimplePatternFileListFilter(this.jobListenerConfiguration.getFilePattern()));
}