Skip to content

Commit

Permalink
[hdpowerview] fix classnotfoundexception (openhab#9224)
Browse files Browse the repository at this point in the history
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
  • Loading branch information
J-N-K committed Dec 4, 2020
1 parent 93b56bd commit cd3063e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

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;
Expand All @@ -26,7 +28,9 @@
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
Expand All @@ -37,6 +41,12 @@
@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) {
Expand All @@ -48,7 +58,7 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) {
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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
public class HDPowerViewHubHandler extends BaseBridgeHandler {

private final Logger logger = LoggerFactory.getLogger(HDPowerViewHubHandler.class);
private final ClientBuilder clientBuilder;

private long refreshInterval;
private long hardRefreshInterval;
Expand All @@ -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
Expand Down Expand Up @@ -114,7 +116,7 @@ public void initialize() {
return;
}

webTargets = new HDPowerViewWebTargets(ClientBuilder.newClient(), host);
webTargets = new HDPowerViewWebTargets(clientBuilder.build(), host);
refreshInterval = config.refresh;
hardRefreshInterval = config.hardRefresh;
schedulePoll();
Expand Down

0 comments on commit cd3063e

Please sign in to comment.