aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/geolocation/UniversalGeolocationProvider.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/geolocation/UniversalGeolocationProvider.java')
-rw-r--r--src/main/java/org/traccar/geolocation/UniversalGeolocationProvider.java14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main/java/org/traccar/geolocation/UniversalGeolocationProvider.java b/src/main/java/org/traccar/geolocation/UniversalGeolocationProvider.java
index f71620d8a..7a3f71ee1 100644
--- a/src/main/java/org/traccar/geolocation/UniversalGeolocationProvider.java
+++ b/src/main/java/org/traccar/geolocation/UniversalGeolocationProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2022 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,26 +15,26 @@
*/
package org.traccar.geolocation;
-import org.traccar.Context;
import org.traccar.model.Network;
import javax.json.JsonObject;
-import javax.ws.rs.client.AsyncInvoker;
+import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.InvocationCallback;
public class UniversalGeolocationProvider implements GeolocationProvider {
- private String url;
+ private final Client client;
+ private final String url;
- public UniversalGeolocationProvider(String url, String key) {
+ public UniversalGeolocationProvider(Client client, String url, String key) {
+ this.client = client;
this.url = url + "?key=" + key;
}
@Override
public void getLocation(Network network, final LocationProviderCallback callback) {
- AsyncInvoker invoker = Context.getClient().target(url).request().async();
- invoker.post(Entity.json(network), new InvocationCallback<JsonObject>() {
+ client.target(url).request().async().post(Entity.json(network), new InvocationCallback<JsonObject>() {
@Override
public void completed(JsonObject json) {
if (json.containsKey("error")) {