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

The following examples show how to use org.springframework.integration.file.filters.AcceptOnceFileListFilter. These examples are extracted from open source projects. 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 Project: java-examples   Source File: SftpConfig.java    License: 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
@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
@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
@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 Project: spring-batch-lightmin   Source File: FolderListener.java    License: 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()));
}