Skip to content

Commit 0558428

Browse files
author
innokenty
committed
upgrade to beanloader 2.1
1 parent b5a4717 commit 0558428

File tree

2 files changed

+11
-23
lines changed

2 files changed

+11
-23
lines changed

proxy/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<dependency>
3131
<groupId>ru.yandex.qatools.beanloader</groupId>
3232
<artifactId>beanloader</artifactId>
33-
<version>2.0</version>
33+
<version>2.1</version>
3434
</dependency>
3535

3636
<!-- Commons -->

proxy/src/main/java/ru/qatools/gridrouter/ConfigRepository.java

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,20 @@
66
import org.springframework.beans.factory.annotation.Value;
77
import org.springframework.stereotype.Repository;
88
import ru.qatools.beanloader.BeanChangeListener;
9+
import ru.qatools.beanloader.BeanLoader;
910
import ru.qatools.beanloader.BeanWatcher;
1011
import ru.qatools.gridrouter.config.Browser;
1112
import ru.qatools.gridrouter.config.Browsers;
1213
import ru.qatools.gridrouter.config.Version;
1314
import ru.qatools.gridrouter.json.JsonCapabilities;
1415

1516
import javax.annotation.PostConstruct;
16-
import javax.xml.bind.JAXB;
17-
import javax.xml.bind.JAXBException;
1817
import java.io.File;
1918
import java.io.IOException;
2019
import java.nio.file.Path;
2120
import java.util.HashMap;
2221
import java.util.Map;
2322

24-
import static java.nio.file.Files.newDirectoryStream;
25-
2623
/**
2724
* @author Alexander Andyashin [email protected]
2825
* @author Dmitry Baev [email protected]
@@ -46,26 +43,17 @@ public class ConfigRepository implements BeanChangeListener<Browsers> {
4643
private Map<String, String> routes = new HashMap<>();
4744

4845
@PostConstruct
49-
public void init() throws JAXBException, IOException {
50-
if (quotaHotReload) {
51-
startQuotaWatcher();
52-
} else {
53-
loadQuotaOnce();
54-
}
55-
}
56-
57-
private void startQuotaWatcher() {
58-
LOGGER.debug("Starting quota watcher");
46+
public void init() {
5947
try {
60-
BeanWatcher.watchFor(Browsers.class, quotaDirectory.getPath(), XML_GLOB, this);
48+
if (quotaHotReload) {
49+
LOGGER.debug("Starting quota watcher");
50+
BeanWatcher.watchFor(Browsers.class, quotaDirectory.toPath(), XML_GLOB, this);
51+
} else {
52+
LOGGER.debug("Loading quota configuration");
53+
BeanLoader.loadAll(Browsers.class, quotaDirectory.toPath(), XML_GLOB, this);
54+
}
6155
} catch (IOException e) {
62-
LOGGER.error("Quota configuration loading failed: \n\n{}", e);
63-
}
64-
}
65-
66-
private void loadQuotaOnce() throws IOException {
67-
for (Path filename : newDirectoryStream(quotaDirectory.toPath(), XML_GLOB)) {
68-
beanChanged(filename, JAXB.unmarshal(filename.toFile(), Browsers.class));
56+
LOGGER.error("Quota configuration loading failed", e);
6957
}
7058
}
7159

0 commit comments

Comments
 (0)