32 |
if (conf.useOpenStreetMaps == false) |
if (conf.useOpenStreetMaps == false) |
33 |
return null; |
return null; |
34 |
|
|
|
limiter.acquire(); |
|
35 |
|
|
36 |
result.osm = true; |
result.osm = true; |
37 |
|
|
38 |
try { |
try { |
39 |
|
|
40 |
OSMInvocation wrapper = new OSMInvocation( conf, request.postnr, request.vejnavn ); |
OSMInvocation wrapper = new OSMInvocation( limiter, conf, request.postnr, request.vejnavn ); |
41 |
CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("osm"); |
CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("osm"); |
42 |
|
|
43 |
result.osmVej = (String) breaker.invoke(wrapper); |
result.osmVej = (String) breaker.invoke(wrapper); |
53 |
int postnr; |
int postnr; |
54 |
String vejnavn; |
String vejnavn; |
55 |
ServiceConfig conf; |
ServiceConfig conf; |
56 |
|
RateLimiter limiter; |
57 |
|
|
58 |
public OSMInvocation(ServiceConfig conf, int postnr, String vejnavn) { |
public OSMInvocation(RateLimiter limiter, ServiceConfig conf, int postnr, String vejnavn) { |
59 |
|
this.limiter = limiter; |
60 |
this.conf = conf; |
this.conf = conf; |
61 |
this.postnr= postnr; |
this.postnr= postnr; |
62 |
this.vejnavn = vejnavn; |
this.vejnavn = vejnavn; |
64 |
|
|
65 |
@Override |
@Override |
66 |
public String proceed() throws Exception { |
public String proceed() throws Exception { |
67 |
|
limiter.acquire(); |
68 |
|
|
69 |
|
|
70 |
//TimingHelper timer = new TimingHelper(); |
//TimingHelper timer = new TimingHelper(); |
71 |
String encVej = URLEncoder.encode(vejnavn, "UTF-8"); |
String encVej = URLEncoder.encode(vejnavn, "UTF-8"); |
72 |
|
|