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

index 7f7e66a2a1484ed23e4f710288a8061cb5ba2eb8..4317f5301610f3cfc84ce1609ed74daac486a9d8 100644 (file)
@@ -24,7 +24,7 @@ import org.openhab.core.thing.ThingTypeUID;
 @NonNullByDefault
 public class SomneoBindingConstants {
 
-    private static final String BINDING_ID = "somneo";
+    public static final String BINDING_ID = "somneo";
 
     // List of all Thing properties
     public static final String PROPERTY_VENDOR_NAME = "Philips";
index d7bbdd3fd95dd3375dcdba623308d86032c59ffe..17f8eda306ff05c43d65ef6f709041e5a54c015b 100644 (file)
@@ -12,7 +12,7 @@
  */
 package org.openhab.binding.somneo.internal;
 
-import static org.openhab.binding.somneo.internal.SomneoBindingConstants.THING_TYPE_HF367X;
+import static org.openhab.binding.somneo.internal.SomneoBindingConstants.*;
 
 import java.util.Set;
 
@@ -20,6 +20,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jetty.client.HttpClient;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
+import org.openhab.core.io.net.http.HttpClientFactory;
 import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.ThingTypeUID;
 import org.openhab.core.thing.binding.BaseThingHandlerFactory;
@@ -50,11 +51,14 @@ public class SomneoHandlerFactory extends BaseThingHandlerFactory implements Htt
     private final SomneoPresetStateDescriptionProvider provider;
 
     @Activate
-    public SomneoHandlerFactory(@Reference SomneoPresetStateDescriptionProvider provider) {
+    public SomneoHandlerFactory(final @Reference HttpClientFactory httpClientFactory,
+            @Reference SomneoPresetStateDescriptionProvider provider) {
         this.provider = provider;
 
-        this.secureClient = new HttpClient(new SslContextFactory.Client(false));
-        this.insecureClient = new HttpClient(new SslContextFactory.Client(true));
+        this.secureClient = httpClientFactory.createHttpClient(BINDING_ID + "-secure",
+                new SslContextFactory.Client(false));
+        this.insecureClient = httpClientFactory.createHttpClient(BINDING_ID + "-insecure",
+                new SslContextFactory.Client(true));
 
         try {
             this.secureClient.start();