summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilip Krzywka <filip.krzywka@nokia.com>2019-02-18 15:32:59 +0100
committerFilip Krzywka <filip.krzywka@nokia.com>2019-02-19 08:33:12 +0100
commit68cef901a37ced72ec7328f6a2749b526330f7f8 (patch)
treee035ec169985a256f431d84332afdae72e756c15
parent244b070d680eaac727091193b0998c76c78cc230 (diff)
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 <filip.krzywka@nokia.com>
-rw-r--r--rest-services/cbs-client/pom.xml4
-rw-r--r--rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClient.java45
-rw-r--r--rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactory.java50
-rw-r--r--rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientImpl.java34
4 files changed, 133 insertions, 0 deletions
diff --git a/rest-services/cbs-client/pom.xml b/rest-services/cbs-client/pom.xml
index 51f6913e..86527e9c 100644
--- a/rest-services/cbs-client/pom.xml
+++ b/rest-services/cbs-client/pom.xml
@@ -52,6 +52,10 @@
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jetbrains</groupId>
+ <artifactId>annotations</artifactId>
+ </dependency>
<dependency>
<groupId>org.mockito</groupId>
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;
+
+/**
+ * <p>Main Config Binding Service client interface.</p>
+ *
+ * <p>User should use this interface to subscribe to events published when CBS client fetches configuration.</p>
+ *
+ * @since 1.1.2
+ */
+public interface CbsClient {
+
+ /**
+ * Get reactive configuration stream.
+ * <p>
+ * 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<JsonObject> 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;
+
+/**
+ * <p>
+ * Factory for Config Binding Service client.
+ * </p>
+ *
+ * @since 1.1.2
+ */
+public class CbsClientFactory {
+
+ /**
+ * <p>Creates Mono which will emit instance of {@link CbsClient} when service discovery is complete.</p>
+ *
+ * <p>
+ * 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.
+ * </p>
+ *
+ * @return non-null {@link Mono} of {@link CbsClient} instance
+ * @since 1.1.2
+ */
+ @NotNull
+ public static Mono<CbsClient> 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<JsonObject> get(String serviceComponentName) {
+ return Mono.empty();
+ }
+}