replace PdbRepository with @Bean annotated method

This commit is contained in:
2017-04-11 18:06:33 +02:00
parent b8b4a6d760
commit cc7e461ebf
5 changed files with 27 additions and 49 deletions

View File

@@ -1,5 +1,13 @@
package org.lucares.pdbui;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.lucares.performance.db.PerformanceDb;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
@@ -9,4 +17,14 @@ import org.springframework.scheduling.annotation.EnableAsync;
@ComponentScan("org.lucares.pdbui")
public class MySpringConfiguration {
private static final Logger LOGGER = LoggerFactory.getLogger(MySpringConfiguration.class);
@Bean
PerformanceDb performanceDb(@Value("${db.base}") final String dbBaseDir) {
final Path dataDirectory = Paths.get(dbBaseDir);
LOGGER.info("using database in {}", dataDirectory.toAbsolutePath());
return new PerformanceDb(dataDirectory);
}
}