Skip to content

Commit

Permalink
Remove MQTT system broker leftovers (openhab#12472)
Browse files Browse the repository at this point in the history
The MqttService was used to keep track of the system MQTT brokers.
Since there are none the dependency can be removed.

Related to: openhab/openhab-core#2842
See also: openhab#12157

Signed-off-by: Wouter Born <github@maindrain.net>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
  • Loading branch information
wborn authored and andrasU committed Nov 12, 2022
1 parent c8f10b3 commit e99308c
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.openhab.core.io.transport.mqtt.MqttBrokerConnection;
import org.openhab.core.io.transport.mqtt.MqttConnectionObserver;
import org.openhab.core.io.transport.mqtt.MqttConnectionState;
import org.openhab.core.io.transport.mqtt.MqttService;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.ChannelUID;
Expand All @@ -41,8 +40,7 @@

/**
* This base implementation handles connection changes of the {@link MqttBrokerConnection}
* and puts the Thing on or offline. It also handles adding/removing notifications of the
* {@link MqttService} and provides a basic dispose() implementation.
* and puts the Thing on or offline. It also provides a basic dispose() implementation.
*
* @author David Graeff - Initial contribution
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.openhab.core.config.core.Configuration;
import org.openhab.core.io.transport.mqtt.MqttBrokerConnection;
import org.openhab.core.io.transport.mqtt.MqttConnectionState;
import org.openhab.core.io.transport.mqtt.MqttService;
import org.openhab.core.io.transport.mqtt.MqttWillAndTestament;
import org.openhab.core.io.transport.mqtt.reconnect.PeriodicReconnectStrategy;
import org.openhab.core.thing.Bridge;
Expand All @@ -41,8 +40,7 @@
/**
* This handler provided more detailed connection information from a
* {@link MqttBrokerConnection} via a Thing property, put the Thing
* offline or online depending on the connection and adds the configured
* connection to the {@link MqttService}.
* offline or online depending on the connection.
*
* @author David Graeff - Initial contribution
* @author Jimmy Tanagra - Add birth and shutdown message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,13 @@
import org.openhab.binding.mqtt.discovery.MQTTTopicDiscoveryService;
import org.openhab.binding.mqtt.handler.AbstractBrokerHandler;
import org.openhab.binding.mqtt.handler.BrokerHandler;
import org.openhab.core.io.transport.mqtt.MqttService;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.Thing;
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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -69,13 +66,6 @@ public class MqttBrokerHandlerFactory extends BaseThingHandlerFactory implements
protected final Set<AbstractBrokerHandler> handlers = Collections
.synchronizedSet(Collections.newSetFromMap(new WeakHashMap<>()));

private MqttService mqttService;

@Activate
public MqttBrokerHandlerFactory(@Reference MqttService mqttService) {
this.mqttService = mqttService;
}

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
Expand All @@ -96,9 +86,6 @@ protected void createdHandler(AbstractBrokerHandler handler) {

@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
if (mqttService == null) {
throw new IllegalStateException("MqttService must be bound, before ThingHandlers can be created");
}
if (!(thing instanceof Bridge)) {
throw new IllegalStateException("A bridge type is expected");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.openhab.core.io.transport.mqtt.MqttBrokerConnection;
import org.openhab.core.io.transport.mqtt.MqttConnectionState;
import org.openhab.core.io.transport.mqtt.MqttException;
import org.openhab.core.io.transport.mqtt.MqttService;
import org.openhab.core.test.java.JavaTest;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.ThingStatus;
Expand All @@ -54,7 +53,6 @@ public class BrokerHandlerTest extends JavaTest {

private @Mock ThingHandlerCallback callback;
private @Mock Bridge thing;
private @Mock MqttService service;

private MqttBrokerConnectionEx connection;

Expand Down Expand Up @@ -83,7 +81,7 @@ public void tearDown() {
public void handlerInitWithoutUrl() throws IllegalArgumentException {
// Assume it is a real handler and not a mock as defined above
handler = new BrokerHandler(thing);
assertThrows(IllegalArgumentException.class, () -> initializeHandlerWaitForTimeout());
assertThrows(IllegalArgumentException.class, this::initializeHandlerWaitForTimeout);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.openhab.binding.mqtt.handler.BrokerHandlerEx;
import org.openhab.binding.mqtt.handler.MqttBrokerConnectionEx;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.io.transport.mqtt.MqttService;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.binding.ThingHandlerCallback;

Expand All @@ -50,9 +49,6 @@ public class MQTTTopicDiscoveryServiceTest {

private MqttBrokerHandlerFactory subject;

@Mock
private MqttService mqttService;

@Mock
private Bridge thing;

Expand Down Expand Up @@ -83,7 +79,7 @@ public void setUp() {
handler = spy(new BrokerHandlerEx(thing, connection));
handler.setCallback(callback);

subject = new MqttBrokerHandlerFactory(mqttService);
subject = new MqttBrokerHandlerFactory();
}

@AfterEach
Expand Down

0 comments on commit e99308c

Please sign in to comment.