summaryrefslogtreecommitdiffstats
path: root/prh-app-server/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'prh-app-server/src/main')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java19
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java33
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java17
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java28
4 files changed, 34 insertions, 63 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java
index 4cde2257..2f947d47 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java
@@ -20,30 +20,21 @@
package org.onap.dcaegen2.services.prh.tasks;
-import org.onap.dcaegen2.services.prh.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.services.prh.service.DMaaPReactiveWebClient;
import org.onap.dcaegen2.services.prh.service.consumer.DMaaPConsumerReactiveHttpClient;
-import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
*/
-abstract class DmaapConsumerTask {
+interface DmaapConsumerTask {
- abstract Flux<ConsumerDmaapModel> consume(Mono<String> message);
+ void initConfigs();
- abstract DMaaPConsumerReactiveHttpClient resolveClient();
+ Flux<ConsumerDmaapModel> execute(String object);
- abstract void initConfigs();
+ Flux<ConsumerDmaapModel> consume(Mono<String> message);
- protected abstract DmaapConsumerConfiguration resolveConfiguration();
-
- protected abstract Flux<ConsumerDmaapModel> execute(String object);
-
- WebClient buildWebClient() {
- return new DMaaPReactiveWebClient().build();
- }
+ DMaaPConsumerReactiveHttpClient resolveClient();
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
index 3a5f213c..c4d9c44a 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
@@ -20,10 +20,9 @@
package org.onap.dcaegen2.services.prh.tasks;
-import org.onap.dcaegen2.services.prh.config.DmaapConsumerConfiguration;
-import org.onap.dcaegen2.services.prh.configuration.AppConfig;
import org.onap.dcaegen2.services.prh.configuration.Config;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
+import org.onap.dcaegen2.services.prh.service.DMaaPReactiveWebClient;
import org.onap.dcaegen2.services.prh.service.DmaapConsumerJsonParser;
import org.onap.dcaegen2.services.prh.service.consumer.DMaaPConsumerReactiveHttpClient;
import org.slf4j.Logger;
@@ -37,26 +36,28 @@ import reactor.core.publisher.Mono;
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
*/
@Component
-public class DmaapConsumerTaskImpl extends DmaapConsumerTask {
+public class DmaapConsumerTaskImpl implements DmaapConsumerTask {
private static final Logger LOGGER = LoggerFactory.getLogger(DmaapConsumerTaskImpl.class);
private final Config config;
- private DmaapConsumerJsonParser dmaapConsumerJsonParser;
+ private final DmaapConsumerJsonParser dmaapConsumerJsonParser;
+ private final DMaaPReactiveWebClient dmaapReactiveWebClient;
@Autowired
public DmaapConsumerTaskImpl(Config config) {
- this.config = config;
- this.dmaapConsumerJsonParser = new DmaapConsumerJsonParser();
+ this(config, new DmaapConsumerJsonParser(), new DMaaPReactiveWebClient());
}
- DmaapConsumerTaskImpl(AppConfig prhAppConfig, DmaapConsumerJsonParser dmaapConsumerJsonParser) {
+ DmaapConsumerTaskImpl(Config prhAppConfig, DmaapConsumerJsonParser dmaapConsumerJsonParser,
+ DMaaPReactiveWebClient dmaapReactiveWebClient) {
this.config = prhAppConfig;
this.dmaapConsumerJsonParser = dmaapConsumerJsonParser;
+ this.dmaapReactiveWebClient = dmaapReactiveWebClient;
}
@Override
- Flux<ConsumerDmaapModel> consume(Mono<String> message) {
- return dmaapConsumerJsonParser.getJsonObject(message);
+ public void initConfigs() {
+ config.initFileStreamReader();
}
@Override
@@ -67,17 +68,13 @@ public class DmaapConsumerTaskImpl extends DmaapConsumerTask {
}
@Override
- void initConfigs() {
- config.initFileStreamReader();
- }
-
- @Override
- protected DmaapConsumerConfiguration resolveConfiguration() {
- return config.getDmaapConsumerConfiguration();
+ public Flux<ConsumerDmaapModel> consume(Mono<String> message) {
+ return dmaapConsumerJsonParser.getJsonObject(message);
}
@Override
- DMaaPConsumerReactiveHttpClient resolveClient() {
- return new DMaaPConsumerReactiveHttpClient(resolveConfiguration()).createDMaaPWebClient(buildWebClient());
+ public DMaaPConsumerReactiveHttpClient resolveClient() {
+ return new DMaaPConsumerReactiveHttpClient(
+ config.getDmaapConsumerConfiguration()).createDMaaPWebClient(dmaapReactiveWebClient.build());
}
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java
index 7a121d5f..dc0a4488 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java
@@ -20,27 +20,20 @@
package org.onap.dcaegen2.services.prh.tasks;
-import org.onap.dcaegen2.services.prh.config.DmaapPublisherConfiguration;
import org.onap.dcaegen2.services.prh.exceptions.PrhTaskException;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.services.prh.service.producer.DMaaPProducerReactiveHttpClient;
+import org.onap.dcaegen2.services.prh.service.producer.DMaaPPublisherReactiveHttpClient;
import org.springframework.http.ResponseEntity;
-import org.springframework.web.client.RestTemplate;
import reactor.core.publisher.Mono;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
*/
-abstract class DmaapPublisherTask {
+interface DmaapPublisherTask {
- abstract Mono<ResponseEntity<String>> publish(ConsumerDmaapModel consumerDmaapModel) throws PrhTaskException;
+ Mono<ResponseEntity<String>> execute(ConsumerDmaapModel consumerDmaapModel) throws PrhTaskException;
- abstract DMaaPProducerReactiveHttpClient resolveClient();
+ Mono<ResponseEntity<String>> publish(ConsumerDmaapModel consumerDmaapModel) throws PrhTaskException;
- protected abstract DmaapPublisherConfiguration resolveConfiguration();
-
- protected abstract Mono<ResponseEntity<String>> execute(ConsumerDmaapModel consumerDmaapModel)
- throws PrhTaskException;
-
- abstract RestTemplate buildWebClient();
+ DMaaPPublisherReactiveHttpClient resolveClient();
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
index 9a4ff2e3..fdc5e625 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
@@ -20,11 +20,10 @@
package org.onap.dcaegen2.services.prh.tasks;
-import org.onap.dcaegen2.services.prh.config.DmaapPublisherConfiguration;
import org.onap.dcaegen2.services.prh.configuration.Config;
import org.onap.dcaegen2.services.prh.exceptions.DmaapNotFoundException;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.services.prh.service.producer.DMaaPProducerReactiveHttpClient;
+import org.onap.dcaegen2.services.prh.service.producer.DMaaPPublisherReactiveHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -37,11 +36,11 @@ import reactor.core.publisher.Mono;
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
*/
@Component
-public class DmaapPublisherTaskImpl extends DmaapPublisherTask {
+public class DmaapPublisherTaskImpl implements DmaapPublisherTask {
private static final Logger LOGGER = LoggerFactory.getLogger(DmaapPublisherTaskImpl.class);
private final Config config;
- private DMaaPProducerReactiveHttpClient dmaapProducerReactiveHttpClient;
+ private DMaaPPublisherReactiveHttpClient dmaapPublisherReactiveHttpClient;
@Autowired
public DmaapPublisherTaskImpl(Config config) {
@@ -49,32 +48,23 @@ public class DmaapPublisherTaskImpl extends DmaapPublisherTask {
}
@Override
- Mono<ResponseEntity<String>> publish(ConsumerDmaapModel consumerDmaapModel) {
- return dmaapProducerReactiveHttpClient.getDMaaPProducerResponse(consumerDmaapModel);
- }
-
- @Override
public Mono<ResponseEntity<String>> execute(ConsumerDmaapModel consumerDmaapModel) throws DmaapNotFoundException {
if (consumerDmaapModel == null) {
throw new DmaapNotFoundException("Invoked null object to DMaaP task");
}
- dmaapProducerReactiveHttpClient = resolveClient();
+ dmaapPublisherReactiveHttpClient = resolveClient();
LOGGER.info("Method called with arg {}", consumerDmaapModel);
return publish(consumerDmaapModel);
}
@Override
- RestTemplate buildWebClient() {
- return new RestTemplate();
- }
-
- @Override
- protected DmaapPublisherConfiguration resolveConfiguration() {
- return config.getDmaapPublisherConfiguration();
+ public Mono<ResponseEntity<String>> publish(ConsumerDmaapModel consumerDmaapModel) {
+ return dmaapPublisherReactiveHttpClient.getDMaaPProducerResponse(consumerDmaapModel);
}
@Override
- DMaaPProducerReactiveHttpClient resolveClient() {
- return new DMaaPProducerReactiveHttpClient(resolveConfiguration()).createDMaaPWebClient(buildWebClient());
+ public DMaaPPublisherReactiveHttpClient resolveClient() {
+ return new DMaaPPublisherReactiveHttpClient(config.getDmaapPublisherConfiguration())
+ .createDMaaPWebClient(new RestTemplate());
}
} \ No newline at end of file