[tapocontrol] Use createHttpClient (#14475)

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
lolodomo 2023-02-22 17:26:47 +01:00 committed by GitHub
parent 884b5e9e83
commit fbf9a9e6a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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