--- dao/DaoAdresseService/src/dk/daoas/daoadresseservice/GeocodeHelper.java 2015/02/24 11:48:58 2364 +++ dao/DaoAdresseService/src/dk/daoas/daoadresseservice/GeocodeHelper.java 2015/02/24 12:23:59 2367 @@ -26,6 +26,7 @@ public static void main(String[] args) throws IOException { ServiceConfig conf = new ServiceConfig(); + conf.osmTimeout = 1000; int post = 8700; String vej = "Enebarvej"; @@ -35,18 +36,18 @@ long stop1 = System.currentTimeMillis(); long start2 = System.currentTimeMillis(); - System.out.println( "OSM:" + GeocodeHelper.openstreetmapHelper(post, vej) ); + System.out.println( "OSM:" + GeocodeHelper.openstreetmapHelper(conf, post, vej) ); long stop2 = System.currentTimeMillis(); System.out.println("Google: " + (stop1-start1)); System.out.println("OSM: " + (stop2-start2)); } - public static String openstreetmapHelper(int postnr, String vejnavn) { + public static String openstreetmapHelper(ServiceConfig conf, int postnr, String vejnavn) { try { - OSMInvocation wrapper = new OSMInvocation( postnr, vejnavn ); + OSMInvocation wrapper = new OSMInvocation( conf, postnr, vejnavn ); CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("osm"); return (String) breaker.invoke(wrapper); @@ -77,8 +78,10 @@ public static class OSMInvocation implements CircuitInvocation { int postnr; String vejnavn; + ServiceConfig conf; - public OSMInvocation(int postnr, String vejnavn) { + public OSMInvocation(ServiceConfig conf, int postnr, String vejnavn) { + this.conf = conf; this.postnr= postnr; this.vejnavn = vejnavn; } @@ -92,7 +95,7 @@ //String url = "http://nominatim.openstreetmap.org/search?country=DK&street=" + encVej + "&format=json&addressdetails=1"; //System.out.println (url); - String json = HttpUtil.getContentString(url, 1000); + String json = HttpUtil.getContentString(url, conf.osmTimeout); //System.out.println(json); Gson gson = new Gson();