Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.Map;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

import org.jspecify.annotations.Nullable;

Expand All @@ -32,7 +31,6 @@
import org.springframework.integration.dsl.ComponentsRegistration;
import org.springframework.integration.dsl.MessageSourceSpec;
import org.springframework.integration.expression.FunctionExpression;
import org.springframework.integration.expression.SupplierExpression;
import org.springframework.integration.file.DirectoryScanner;
import org.springframework.integration.file.FileLocker;
import org.springframework.integration.file.RecursiveDirectoryScanner;
Expand All @@ -54,7 +52,7 @@ public class FileInboundChannelAdapterSpec
extends MessageSourceSpec<FileInboundChannelAdapterSpec, FileReadingMessageSource>
implements ComponentsRegistration {

protected final FileListFilterFactoryBean fileListFilterFactoryBean = new FileListFilterFactoryBean(); // NOSONAR
protected final FileListFilterFactoryBean fileListFilterFactoryBean = new FileListFilterFactoryBean();

private @Nullable FileLocker locker;

Expand All @@ -73,18 +71,18 @@ protected FileInboundChannelAdapterSpec(@Nullable Comparator<File> receptionOrde
}

/**
* Specify the Supplier for input directory.
* @param directorySupplier the Supplier for directory to poll.
* Specify the SpEL expression for the input directory.
* @param directoryExpression the SpEL expression for directory to poll.
* @return the spec.
* @see FileReadingMessageSource#setDirectoryExpression(Expression)
*/
FileInboundChannelAdapterSpec directory(Supplier<File> directorySupplier) {
this.target.setDirectoryExpression(new SupplierExpression<>(directorySupplier));
FileInboundChannelAdapterSpec directory(Expression directoryExpression) {
this.target.setDirectoryExpression(directoryExpression);
return _this();
}

/**
* A convenient flag to determine if target message source should use a
* A convenient flag to determine if a target message source should use a
* {@link RecursiveDirectoryScanner} or stay with a default one.
* @param recursive to set or not a {@link RecursiveDirectoryScanner}.
* @return the spec.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.jspecify.annotations.Nullable;

import org.springframework.expression.Expression;
import org.springframework.integration.expression.SupplierExpression;
import org.springframework.integration.expression.ValueExpression;
import org.springframework.integration.file.transformer.FileToByteArrayTransformer;
import org.springframework.integration.file.transformer.FileToStringTransformer;
import org.springframework.messaging.Message;
Expand All @@ -43,7 +45,7 @@ public abstract class Files {
* @return the {@link FileInboundChannelAdapterSpec} instance.
*/
public static FileInboundChannelAdapterSpec inboundAdapter(File directory) {
return inboundAdapter(() -> directory);
return inboundAdapter(directory, null);
}

/**
Expand All @@ -65,7 +67,8 @@ public static FileInboundChannelAdapterSpec inboundAdapter(Supplier<File> direct
public static FileInboundChannelAdapterSpec inboundAdapter(File directory,
@Nullable Comparator<File> receptionOrderComparator) {

return inboundAdapter(() -> directory, null);
return new FileInboundChannelAdapterSpec(receptionOrderComparator)
.directory(new ValueExpression<>(directory));
}

/**
Expand All @@ -78,7 +81,8 @@ public static FileInboundChannelAdapterSpec inboundAdapter(File directory,
public static FileInboundChannelAdapterSpec inboundAdapter(Supplier<File> directorySupplier,
@Nullable Comparator<File> receptionOrderComparator) {

return new FileInboundChannelAdapterSpec(receptionOrderComparator).directory(directorySupplier);
return new FileInboundChannelAdapterSpec(receptionOrderComparator)
.directory(new SupplierExpression<>(directorySupplier));
}

/**
Expand All @@ -92,7 +96,7 @@ public static FileWritingMessageHandlerSpec outboundAdapter(File destinationDire

/**
* Create a {@link FileWritingMessageHandlerSpec} builder for the one-way {@code FileWritingMessageHandler}.
* @param directoryExpression the SpEL expression to evaluate target directory for writing files.
* @param directoryExpression the SpEL expression to evaluate the target directory for writing files.
* @return the {@link FileWritingMessageHandlerSpec} instance.
*/
public static FileWritingMessageHandlerSpec outboundAdapter(String directoryExpression) {
Expand Down Expand Up @@ -129,7 +133,7 @@ public static FileWritingMessageHandlerSpec outboundGateway(File destinationDire

/**
* Create a {@link FileWritingMessageHandlerSpec} builder for the gateway {@code FileWritingMessageHandler}.
* @param directoryExpression the SpEL expression to evaluate target directory for writing files.
* @param directoryExpression the SpEL expression to evaluate the target directory for writing files.
* @return the {@link FileWritingMessageHandlerSpec} instance.
*/
public static FileWritingMessageHandlerSpec outboundGateway(String directoryExpression) {
Expand Down Expand Up @@ -193,15 +197,15 @@ public static FileSplitterSpec splitter(boolean iterator, boolean markers) {
}

/**
* Create a {@link FileToStringTransformer} instance with default {@code charset} and no delete files afterwards.
* Create a {@link FileToStringTransformer} instance with default {@code charset} and no delete files afterward.
* @return the {@link FileToStringTransformer}.
*/
public static FileToStringTransformer toStringTransformer() {
return toStringTransformer(false);
}

/**
* Create a {@link FileToStringTransformer} instance with default {@code charset} and with delete files flag.
* Create a {@link FileToStringTransformer} instance with default {@code charset} and the flag to delete files.
* @param deleteFiles true to delete the file.
* @return the {@link FileToStringTransformer}.
*/
Expand All @@ -210,7 +214,7 @@ public static FileToStringTransformer toStringTransformer(boolean deleteFiles) {
}

/**
* Create a {@link FileToStringTransformer} instance with provided {@code charset} and no delete files afterwards.
* Create a {@link FileToStringTransformer} instance with provided {@code charset} and no delete files afterward.
* @param charset The charset.
* @return the {@link FileToStringTransformer}.
*/
Expand All @@ -219,7 +223,7 @@ public static FileToStringTransformer toStringTransformer(String charset) {
}

/**
* Create a {@link FileToStringTransformer} instance with provided {@code charset} and delete files flag.
* Create a {@link FileToStringTransformer} instance with provided {@code charset} and the flag to delete files.
* @param charset The charset.
* @param deleteFiles true to delete the file.
* @return the {@link FileToStringTransformer}.
Expand All @@ -244,7 +248,7 @@ public static FileToByteArrayTransformer toByteArrayTransformer() {
/**
* Create a {@link FileToByteArrayTransformer} instance.
* @param deleteFiles specify whether to delete the File after transformation.
* Default is <em>false</em>.
* Default is {@code false}.
* @return the {@link FileToByteArrayTransformer}.
*/
public static FileToByteArrayTransformer toByteArrayTransformer(boolean deleteFiles) {
Expand Down