Prepare CBS client for future changes 65/78665/2
authorFilip Krzywka <filip.krzywka@nokia.com>
Mon, 18 Feb 2019 14:32:59 +0000 (15:32 +0100)
committerFilip Krzywka <filip.krzywka@nokia.com>
Tue, 19 Feb 2019 07:33:12 +0000 (08:33 +0100)
Skeleton of module definition for CBS client.

Change-Id: I62e7f599a36d8d159d6d5c9b09fcf3744ad9dbc1
Issue-ID: DCAEGEN2-1234
Signed-off-by: Filip Krzywka <filip.krzywka@nokia.com>
rest-services/cbs-client/pom.xml
rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClient.java [new file with mode: 0644]
rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactory.java [new file with mode: 0644]
rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientImpl.java [new file with mode: 0644]

index 51f6913..86527e9 100644 (file)
       <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 (file)
index 0000000..0f50fca
--- /dev/null
@@ -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 (file)
index 0000000..f81cd6b
--- /dev/null
@@ -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 (file)
index 0000000..7bd80ed
--- /dev/null
@@ -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();
+    }
+}