[hdpowerview] fix classnotfoundexception (#9224)

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
This commit is contained in:
J-N-K 2020-12-04 19:25:41 +01:00 committed by GitHub
parent 35528eda3b
commit 97d9bda0a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -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)) {

View File

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