From 97d9bda0a1840c0519d3594716e3cfc3b33c9eca Mon Sep 17 00:00:00 2001 From: J-N-K Date: Fri, 4 Dec 2020 19:25:41 +0100 Subject: [PATCH] [hdpowerview] fix classnotfoundexception (#9224) Signed-off-by: Jan N. Klug --- .../internal/HDPowerViewHandlerFactory.java | 12 +++++++++++- .../internal/handler/HDPowerViewHubHandler.java | 6 ++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/HDPowerViewHandlerFactory.java b/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/HDPowerViewHandlerFactory.java index 3477fe845..126e97427 100644 --- a/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/HDPowerViewHandlerFactory.java +++ b/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/HDPowerViewHandlerFactory.java @@ -14,6 +14,8 @@ package org.openhab.binding.hdpowerview.internal; import java.util.Hashtable; +import javax.ws.rs.client.ClientBuilder; + import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.hdpowerview.internal.discovery.HDPowerViewShadeDiscoveryService; @@ -26,7 +28,9 @@ import org.openhab.core.thing.ThingTypeUID; import org.openhab.core.thing.binding.BaseThingHandlerFactory; import org.openhab.core.thing.binding.ThingHandler; import org.openhab.core.thing.binding.ThingHandlerFactory; +import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; /** * The {@link HDPowerViewHandlerFactory} is responsible for creating things and thing @@ -37,6 +41,12 @@ import org.osgi.service.component.annotations.Component; @NonNullByDefault @Component(service = ThingHandlerFactory.class, configurationPid = "binding.hdpowerview") public class HDPowerViewHandlerFactory extends BaseThingHandlerFactory { + private final ClientBuilder clientBuilder; + + @Activate + public HDPowerViewHandlerFactory(@Reference ClientBuilder clientBuilder) { + this.clientBuilder = clientBuilder; + } @Override public boolean supportsThingType(ThingTypeUID thingTypeUID) { @@ -48,7 +58,7 @@ public class HDPowerViewHandlerFactory extends BaseThingHandlerFactory { ThingTypeUID thingTypeUID = thing.getThingTypeUID(); if (thingTypeUID.equals(HDPowerViewBindingConstants.THING_TYPE_HUB)) { - HDPowerViewHubHandler handler = new HDPowerViewHubHandler((Bridge) thing); + HDPowerViewHubHandler handler = new HDPowerViewHubHandler((Bridge) thing, clientBuilder); registerService(new HDPowerViewShadeDiscoveryService(handler)); return handler; } else if (thingTypeUID.equals(HDPowerViewBindingConstants.THING_TYPE_SHADE)) { diff --git a/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewHubHandler.java b/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewHubHandler.java index f7777d7ac..6d337c0d2 100644 --- a/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewHubHandler.java +++ b/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewHubHandler.java @@ -63,6 +63,7 @@ import com.google.gson.JsonParseException; public class HDPowerViewHubHandler extends BaseBridgeHandler { private final Logger logger = LoggerFactory.getLogger(HDPowerViewHubHandler.class); + private final ClientBuilder clientBuilder; private long refreshInterval; private long hardRefreshInterval; @@ -74,8 +75,9 @@ public class HDPowerViewHubHandler extends BaseBridgeHandler { private final ChannelTypeUID sceneChannelTypeUID = new ChannelTypeUID(HDPowerViewBindingConstants.BINDING_ID, HDPowerViewBindingConstants.CHANNELTYPE_SCENE_ACTIVATE); - public HDPowerViewHubHandler(Bridge bridge) { + public HDPowerViewHubHandler(Bridge bridge, ClientBuilder clientBuilder) { super(bridge); + this.clientBuilder = clientBuilder; } @Override @@ -114,7 +116,7 @@ public class HDPowerViewHubHandler extends BaseBridgeHandler { return; } - webTargets = new HDPowerViewWebTargets(ClientBuilder.newClient(), host); + webTargets = new HDPowerViewWebTargets(clientBuilder.build(), host); refreshInterval = config.refresh; hardRefreshInterval = config.hardRefresh; schedulePoll();