io.quarkiverse.doma.runtime.devmode.HotReplacementScriptFileLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-doma Show documentation
Show all versions of quarkus-doma Show documentation
Simplify your database accesses with compile-time code generation
The newest version!
package io.quarkiverse.doma.runtime.devmode;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import org.seasar.doma.jdbc.ScriptFileLoader;
public class HotReplacementScriptFileLoader implements ScriptFileLoader {
private final List resourcesDirs;
public HotReplacementScriptFileLoader(List resourcesDirs) {
Objects.requireNonNull(resourcesDirs);
this.resourcesDirs = Collections.unmodifiableList(resourcesDirs);
}
@Override
public URL loadAsURL(String path) {
for (Path dir : resourcesDirs) {
Path file = dir.resolve(path);
if (Files.exists(file)) {
try {
return file.toUri().toURL();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
return null;
}
}