Skip to content

Commit

Permalink
Remove default namespace configuration
Browse files Browse the repository at this point in the history
* This adds unnecessary complexity/dependency.
  It's required that client and ditto instance have same config, otherwise
  things went strange. Leave responsibility for resolving the default
  namespace to the service.

Signed-off-by: Yannic Klem <Yannic.Klem@bosch.io>
  • Loading branch information
Yannic92 committed May 30, 2022
1 parent 6e36b4c commit 262a8fe
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 39 deletions.
Expand Up @@ -45,15 +45,6 @@ public interface MessagingConfiguration {
*/
JsonSchemaVersion getJsonSchemaVersion();

/**
* Returns the default namespace for entity creation (things/policies) when no explicit namespace was
* provided, e.g. for "create" methods.
*
* @return the default namespace.
* @since 3.0.0
*/
Optional<String> getDefaultNamespace();

/**
* Returns the Ditto endpoint URI to use for messaging.
*
Expand Down Expand Up @@ -141,16 +132,6 @@ interface Builder {
*/
Builder endpoint(String endpoint);

/**
* Configures the default namespace for entity creation (things/policies) when no explicit namespace was
* provided, e.g. for "create" methods.
*
* @param defaultNamespace the default namespace to use within the messaging configuration.
* @return this builder.
* @since 3.0.0
*/
Builder defaultNamespace(String defaultNamespace);

/**
* Sets the labels of all acknowledgements that are declared to be provided by this client session/connection.
*
Expand Down
Expand Up @@ -43,7 +43,6 @@ public final class WebSocketMessagingConfiguration implements MessagingConfigura

private final Duration timeout;
private final JsonSchemaVersion jsonSchemaVersion;
@Nullable private final String defaultNamespace;
private final URI endpointUri;
private final boolean reconnectEnabled;
private final boolean initialConnectRetryEnabled;
Expand All @@ -57,7 +56,6 @@ public WebSocketMessagingConfiguration(final WebSocketMessagingConfigurationBuil
final URI endpointUri) {

jsonSchemaVersion = builder.jsonSchemaVersion;
defaultNamespace = builder.defaultNamespace;
reconnectEnabled = builder.reconnectEnabled;
initialConnectRetryEnabled = builder.initialConnectRetryEnabled;
proxyConfiguration = builder.proxyConfiguration;
Expand All @@ -83,11 +81,6 @@ public JsonSchemaVersion getJsonSchemaVersion() {
return jsonSchemaVersion;
}

@Override
public Optional<String> getDefaultNamespace() {
return Optional.ofNullable(defaultNamespace);
}

@Override
public URI getEndpointUri() {
return endpointUri;
Expand Down Expand Up @@ -137,7 +130,6 @@ private static final class WebSocketMessagingConfigurationBuilder implements Mes
private JsonSchemaVersion jsonSchemaVersion;
private Duration timeout = Duration.ofSeconds(60L);
private URI endpointUri;
@Nullable private String defaultNamespace;
private boolean reconnectEnabled;
private boolean initialConnectRetryEnabled;
@Nullable private ProxyConfiguration proxyConfiguration;
Expand All @@ -148,7 +140,6 @@ private static final class WebSocketMessagingConfigurationBuilder implements Mes

private WebSocketMessagingConfigurationBuilder() {
jsonSchemaVersion = JsonSchemaVersion.LATEST;
defaultNamespace = null;
reconnectEnabled = true;
initialConnectRetryEnabled = false;
proxyConfiguration = null;
Expand Down Expand Up @@ -181,12 +172,6 @@ public MessagingConfiguration.Builder endpoint(final String endpoint) {
return this;
}

@Override
public Builder defaultNamespace(final String defaultNamespace) {
this.defaultNamespace = checkNotNull(defaultNamespace, "defaultNamespace");
return this;
}

@Override
public Builder declaredAcknowledgements(final Collection<AcknowledgementLabel> acknowledgementLabels) {
this.declaredAcknowledgements.clear();
Expand Down
Expand Up @@ -19,7 +19,6 @@

import org.eclipse.ditto.base.model.acks.AcknowledgementLabelNotDeclaredException;
import org.eclipse.ditto.base.model.acks.AcknowledgementLabelNotUniqueException;
import org.eclipse.ditto.base.model.common.DittoSystemProperties;
import org.eclipse.ditto.base.model.headers.DittoHeaderDefinition;
import org.eclipse.ditto.base.model.headers.DittoHeadersBuilder;
import org.eclipse.ditto.base.model.json.JsonSchemaVersion;
Expand Down Expand Up @@ -215,8 +214,6 @@ private static TwinImpl configureTwin(final MessagingProvider messagingProvider)
final PointerBus bus = BusFactory.createPointerBus(name, messagingProvider.getExecutorService());
init(bus, messagingProvider);
final MessagingConfiguration messagingConfiguration = messagingProvider.getMessagingConfiguration();
messagingConfiguration.getDefaultNamespace().ifPresent(defaultNamespace ->
System.setProperty(DittoSystemProperties.DITTO_ENTITY_CREATION_DEFAULT_NAMESPACE, defaultNamespace));
final JsonSchemaVersion schemaVersion = messagingConfiguration.getJsonSchemaVersion();
final OutgoingMessageFactory messageFactory = OutgoingMessageFactory.newInstance(schemaVersion);
return TwinImpl.newInstance(messagingProvider, messageFactory, bus);
Expand All @@ -238,8 +235,6 @@ private static PoliciesImpl configurePolicyClient(final MessagingProvider messag
final PointerBus bus = BusFactory.createPointerBus(busName, messagingProvider.getExecutorService());
init(bus, messagingProvider);
final MessagingConfiguration messagingConfiguration = messagingProvider.getMessagingConfiguration();
messagingConfiguration.getDefaultNamespace().ifPresent(defaultNamespace ->
System.setProperty(DittoSystemProperties.DITTO_ENTITY_CREATION_DEFAULT_NAMESPACE, defaultNamespace));
final OutgoingMessageFactory messageFactory = getOutgoingMessageFactoryForPolicies(messagingProvider);
return PoliciesImpl.newInstance(messagingProvider, messageFactory, bus);
}
Expand Down

0 comments on commit 262a8fe

Please sign in to comment.