6
6
import org .springframework .beans .factory .annotation .Value ;
7
7
import org .springframework .stereotype .Repository ;
8
8
import ru .qatools .beanloader .BeanChangeListener ;
9
+ import ru .qatools .beanloader .BeanLoader ;
9
10
import ru .qatools .beanloader .BeanWatcher ;
10
11
import ru .qatools .gridrouter .config .Browser ;
11
12
import ru .qatools .gridrouter .config .Browsers ;
12
13
import ru .qatools .gridrouter .config .Version ;
13
14
import ru .qatools .gridrouter .json .JsonCapabilities ;
14
15
15
16
import javax .annotation .PostConstruct ;
16
- import javax .xml .bind .JAXB ;
17
- import javax .xml .bind .JAXBException ;
18
17
import java .io .File ;
19
18
import java .io .IOException ;
20
19
import java .nio .file .Path ;
21
20
import java .util .HashMap ;
22
21
import java .util .Map ;
23
22
24
- import static java .nio .file .Files .newDirectoryStream ;
25
-
26
23
/**
27
24
* @author Alexander Andyashin [email protected]
28
25
* @author Dmitry Baev [email protected]
@@ -46,26 +43,17 @@ public class ConfigRepository implements BeanChangeListener<Browsers> {
46
43
private Map <String , String > routes = new HashMap <>();
47
44
48
45
@ 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 () {
59
47
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
+ }
61
55
} 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 );
69
57
}
70
58
}
71
59
0 commit comments