io.quarkiverse.doma.runtime.devmode.HotReplacementSqlFileRepository 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.lang.reflect.Method;
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.AbstractSqlFileRepository;
import org.seasar.doma.jdbc.SqlFile;
import org.seasar.doma.jdbc.dialect.Dialect;
public class HotReplacementSqlFileRepository extends AbstractSqlFileRepository {
private final List resourcesDirs;
public HotReplacementSqlFileRepository(List resourcesDirs) {
Objects.requireNonNull(resourcesDirs);
this.resourcesDirs = Collections.unmodifiableList(resourcesDirs);
}
@Override
protected SqlFile getSqlFileWithCacheControl(Method method, String path, Dialect dialect) {
return createSqlFile(method, path, dialect);
}
@Override
protected String getSql(String path) {
for (Path dir : resourcesDirs) {
Path file = dir.resolve(path);
if (Files.exists(file)) {
try {
return Files.readString(file);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
return null;
}
}