Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add connectivity announcements to the ditto protocol
Signed-off-by: Florian Fendt <Florian.Fendt@bosch.io>
- Loading branch information
Showing
32 changed files
with
961 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...ain/java/org/eclipse/ditto/protocol/adapter/connectivity/AbstractConnectivityAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) 2021 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.eclipse.ditto.protocol.adapter.connectivity; | ||
|
||
import org.eclipse.ditto.base.model.signals.Signal; | ||
import org.eclipse.ditto.protocol.Adaptable; | ||
import org.eclipse.ditto.protocol.HeaderTranslator; | ||
import org.eclipse.ditto.protocol.TopicPath; | ||
import org.eclipse.ditto.protocol.adapter.AbstractAdapter; | ||
import org.eclipse.ditto.protocol.adapter.EmptyPathMatcher; | ||
import org.eclipse.ditto.protocol.mapper.SignalMapper; | ||
import org.eclipse.ditto.protocol.mappingstrategies.MappingStrategies; | ||
|
||
/** | ||
* Base class for {@link org.eclipse.ditto.protocol.adapter.Adapter}s that handle connectivity commands. | ||
* | ||
* @param <T> the type of the connectivity command | ||
* @since 2.1.0 | ||
*/ | ||
abstract class AbstractConnectivityAdapter<T extends Signal<?>> extends AbstractAdapter<T> implements ConnectivityAdapter<T> { | ||
|
||
private final SignalMapper<T> signalMapper; | ||
|
||
/** | ||
* @param mappingStrategies the {@link MappingStrategies} used to convert {@link Adaptable}s to | ||
* {@link Signal}s | ||
* @param signalMapper the {@link SignalMapper} used to convert from a | ||
* {@link Signal} to an {@link Adaptable} | ||
* @param headerTranslator the header translator | ||
*/ | ||
protected AbstractConnectivityAdapter(final MappingStrategies<T> mappingStrategies, | ||
final SignalMapper<T> signalMapper, final HeaderTranslator headerTranslator) { | ||
super(mappingStrategies, headerTranslator, EmptyPathMatcher.getInstance()); | ||
this.signalMapper = signalMapper; | ||
} | ||
|
||
@Override | ||
protected Adaptable mapSignalToAdaptable(final T signal, final TopicPath.Channel channel) { | ||
return signalMapper.mapSignalToAdaptable(signal, channel); | ||
} | ||
|
||
@Override | ||
public Adaptable toAdaptable(final T t) { | ||
return super.toAdaptable(t, TopicPath.Channel.NONE); | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
...ol/src/main/java/org/eclipse/ditto/protocol/adapter/connectivity/ConnectivityAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2021 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.eclipse.ditto.protocol.adapter.connectivity; | ||
|
||
import java.util.EnumSet; | ||
import java.util.Set; | ||
|
||
import org.eclipse.ditto.base.model.signals.Signal; | ||
import org.eclipse.ditto.protocol.TopicPath; | ||
import org.eclipse.ditto.protocol.adapter.Adapter; | ||
|
||
/** | ||
* Mixin for connectivity adapters. | ||
* | ||
* @since 2.1.0 | ||
*/ | ||
interface ConnectivityAdapter<T extends Signal<?>> extends Adapter<T> { | ||
|
||
@Override | ||
default Set<TopicPath.Group> getGroups() { | ||
return EnumSet.of(TopicPath.Group.CONNECTIONS); | ||
} | ||
|
||
@Override | ||
default Set<TopicPath.Channel> getChannels() { | ||
return EnumSet.of(TopicPath.Channel.NONE); | ||
} | ||
|
||
} |
Oops, something went wrong.