name.nkonev.r2dbc.migrate.reader.SpringResourceReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of r2dbc-migrate-resource-reader-spring Show documentation
Show all versions of r2dbc-migrate-resource-reader-spring Show documentation
R2DBC Migrate Reader API Spring implementation
package name.nkonev.r2dbc.migrate.reader;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
public class SpringResourceReader implements MigrateResourceReader {
private final ResourcePatternResolver resolver;
public SpringResourceReader() {
resolver = new PathMatchingResourcePatternResolver();
}
public SpringResourceReader(ResourcePatternResolver resourcePatternResolver) {
resolver = resourcePatternResolver;
}
@Override
public List getResources(String resourcesPath) {
try {
org.springframework.core.io.Resource[] resources = resolver.getResources(resourcesPath);
return Arrays.stream(resources).map(SpringResource::new).collect(Collectors.toList());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}