From 68cef901a37ced72ec7328f6a2749b526330f7f8 Mon Sep 17 00:00:00 2001 From: Filip Krzywka Date: Mon, 18 Feb 2019 15:32:59 +0100 Subject: Prepare CBS client for future changes Skeleton of module definition for CBS client. Change-Id: I62e7f599a36d8d159d6d5c9b09fcf3744ad9dbc1 Issue-ID: DCAEGEN2-1234 Signed-off-by: Filip Krzywka --- .../rest/services/cbs/client/api/CbsClient.java | 45 +++++++++++++++++++ .../services/cbs/client/api/CbsClientFactory.java | 50 ++++++++++++++++++++++ .../services/cbs/client/impl/CbsClientImpl.java | 34 +++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClient.java create mode 100644 rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactory.java create mode 100644 rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientImpl.java (limited to 'rest-services/cbs-client/src') diff --git a/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClient.java b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClient.java new file mode 100644 index 00000000..0f50fca8 --- /dev/null +++ b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClient.java @@ -0,0 +1,45 @@ +/* + * ============LICENSE_START======================================================= + * DCAEGEN2-SERVICES-SDK + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api; + +import com.google.gson.JsonObject; +import reactor.core.publisher.Mono; +import org.jetbrains.annotations.NotNull; + +/** + *

Main Config Binding Service client interface.

+ * + *

User should use this interface to subscribe to events published when CBS client fetches configuration.

+ * + * @since 1.1.2 + */ +public interface CbsClient { + + /** + * Get reactive configuration stream. + *

+ * Returns a {@link Mono} that publishes new configuration after CBS client retrieves one. + * + * @param serviceComponentName url key under which CBS client should look for configuration + * @return reactive stream of configuration + * @since 1.1.2 + */ + @NotNull Mono get(String serviceComponentName); +} diff --git a/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactory.java b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactory.java new file mode 100644 index 00000000..f81cd6b5 --- /dev/null +++ b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactory.java @@ -0,0 +1,50 @@ +/* + * ============LICENSE_START======================================================= + * DCAEGEN2-SERVICES-SDK + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api; + +import org.jetbrains.annotations.NotNull; +import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.impl.CbsClientImpl; +import reactor.core.publisher.Mono; + +/** + *

+ * Factory for Config Binding Service client. + *

+ * + * @since 1.1.2 + */ +public class CbsClientFactory { + + /** + *

Creates Mono which will emit instance of {@link CbsClient} when service discovery is complete.

+ * + *

+ * This method will do a lookup of Config Binding Service using Consul as service discovery mechanism and create + * client configured with found address. Created client will be published in returned Mono instance. + *

+ * + * @return non-null {@link Mono} of {@link CbsClient} instance + * @since 1.1.2 + */ + @NotNull + public static Mono createCbsClient() { + return Mono.just(new CbsClientImpl()); + } +} diff --git a/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientImpl.java b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientImpl.java new file mode 100644 index 00000000..7bd80ed7 --- /dev/null +++ b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientImpl.java @@ -0,0 +1,34 @@ +/* + * ============LICENSE_START======================================================= + * DCAEGEN2-SERVICES-SDK + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.dcaegen2.services.sdk.rest.services.cbs.client.impl; + +import com.google.gson.JsonObject; +import org.jetbrains.annotations.NotNull; +import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsClient; +import reactor.core.publisher.Mono; + +public class CbsClientImpl implements CbsClient { + + @NotNull + @Override + public Mono get(String serviceComponentName) { + return Mono.empty(); + } +} -- cgit 1.2.3-korg