Skip to content

Commit b5a4717

Browse files
author
innokenty
committed
inline redundant private getters in ConfigRepository
1 parent 3eb8e3c commit b5a4717

File tree

1 file changed

+7
-27
lines changed

1 file changed

+7
-27
lines changed

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

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,24 @@ public class ConfigRepository implements BeanChangeListener<Browsers> {
4747

4848
@PostConstruct
4949
public void init() throws JAXBException, IOException {
50-
if (isQuotaHotReload()) {
50+
if (quotaHotReload) {
5151
startQuotaWatcher();
5252
} else {
53-
loadQuotaOnce(getQuotaPath());
53+
loadQuotaOnce();
5454
}
5555
}
5656

5757
private void startQuotaWatcher() {
5858
LOGGER.debug("Starting quota watcher");
5959
try {
60-
BeanWatcher.watchFor(Browsers.class, getQuotaPath().toString(), XML_GLOB, this);
60+
BeanWatcher.watchFor(Browsers.class, quotaDirectory.getPath(), XML_GLOB, this);
6161
} catch (IOException e) {
6262
LOGGER.error("Quota configuration loading failed: \n\n{}", e);
6363
}
6464
}
6565

66-
private void loadQuotaOnce(Path quotaPath) throws IOException {
67-
for (Path filename : newDirectoryStream(quotaPath, XML_GLOB)) {
66+
private void loadQuotaOnce() throws IOException {
67+
for (Path filename : newDirectoryStream(quotaDirectory.toPath(), XML_GLOB)) {
6868
beanChanged(filename, JAXB.unmarshal(filename.toFile(), Browsers.class));
6969
}
7070
}
@@ -76,45 +76,25 @@ public void beanChanged(Path filename, Browsers browsers) {
7676
+ "It is not purged from the running gridrouter process though.", filename);
7777
} else {
7878
LOGGER.info("Loading quota configuration file [{}]", filename);
79-
String user = getFileName(filename);
79+
String user = FilenameUtils.getBaseName(filename.toString());
8080
userBrowsers.put(user, browsers);
8181
routes.putAll(browsers.getRoutesMap());
8282
LOGGER.info("Loaded quota configuration for [{}] from [{}]: \n\n{}",
8383
user, filename, browsers.toXml());
8484
}
8585
}
8686

87-
protected boolean isQuotaHotReload() {
88-
return quotaHotReload;
89-
}
90-
91-
protected Path getQuotaPath() {
92-
return quotaDirectory.toPath();
93-
}
94-
9587
public Map<String, String> getRoutes() {
9688
return routes;
9789
}
9890

99-
public Map<String, Browsers> getUserBrowsers() {
100-
return this.userBrowsers;
101-
}
102-
103-
protected Browsers getUserBrowsers(String user) {
104-
return getUserBrowsers().get(user);
105-
}
106-
10791
public Version findVersion(String user, JsonCapabilities caps) {
10892
return userBrowsers.get(user).find(caps.getBrowserName(), caps.getVersion());
10993
}
11094

111-
private static String getFileName(Path path) {
112-
return FilenameUtils.getBaseName(path.toString());
113-
}
114-
11595
public Map<String, Integer> getBrowsersCountMap(String user) {
11696
HashMap<String, Integer> countMap = new HashMap<>();
117-
for (Browser browser : getUserBrowsers(user).getBrowsers()) {
97+
for (Browser browser : this.userBrowsers.get(user).getBrowsers()) {
11898
for (Version version : browser.getVersions()) {
11999
countMap.put(browser.getName() + ":" + version.getNumber(), version.getCount());
120100
}

0 commit comments

Comments
 (0)