]> git.basschouten.com Git - openhab-addons.git/commitdiff
[tapocontrol] Use createHttpClient (#14475)
authorlolodomo <lg.hc@free.fr>
Wed, 22 Feb 2023 16:26:47 +0000 (17:26 +0100)
committerGitHub <noreply@github.com>
Wed, 22 Feb 2023 16:26:47 +0000 (17:26 +0100)
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/TapoControlHandlerFactory.java

index 6eda41b101843099b56ca99e8193c42791d1c641..5d0b2086e422289095dc372469de8e53d60ca1c1 100644 (file)
@@ -27,6 +27,7 @@ import org.openhab.binding.tapocontrol.internal.device.TapoLightStrip;
 import org.openhab.binding.tapocontrol.internal.device.TapoSmartBulb;
 import org.openhab.binding.tapocontrol.internal.device.TapoSmartPlug;
 import org.openhab.binding.tapocontrol.internal.device.TapoUniversalDevice;
+import org.openhab.core.io.net.http.HttpClientFactory;
 import org.openhab.core.thing.Bridge;
 import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.ThingTypeUID;
@@ -37,6 +38,7 @@ import org.osgi.service.component.ComponentContext;
 import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -54,9 +56,9 @@ public class TapoControlHandlerFactory extends BaseThingHandlerFactory {
     private final HttpClient httpClient;
 
     @Activate
-    public TapoControlHandlerFactory() {
+    public TapoControlHandlerFactory(final @Reference HttpClientFactory httpClientFactory) {
         // create new httpClient
-        httpClient = new HttpClient(new SslContextFactory.Client());
+        httpClient = httpClientFactory.createHttpClient(BINDING_ID, new SslContextFactory.Client());
         httpClient.setFollowRedirects(false);
         httpClient.setMaxConnectionsPerDestination(HTTP_MAX_CONNECTIONS);
         httpClient.setMaxRequestsQueuedPerDestination(HTTP_MAX_QUEUED_REQUESTS);