[somneo] Use createHttpClient (#14477)

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
lolodomo 2023-02-22 17:28:02 +01:00 committed by GitHub
parent fbf9a9e6a9
commit fa7e4e7594
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View 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";

View 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();