aboutsummaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners
diff options
context:
space:
mode:
Diffstat (limited to 'policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners')
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/JsonListener.java13
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/MessageTypeDispatcher.java6
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcher.java6
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/ScoListener.java15
4 files changed, 16 insertions, 24 deletions
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/JsonListener.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/JsonListener.java
index ff8cbc5b..2e171070 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/JsonListener.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/JsonListener.java
@@ -2,7 +2,8 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020 Bell Canada. 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.
@@ -20,6 +21,8 @@
package org.onap.policy.common.endpoints.listeners;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
import org.onap.policy.common.utils.coder.Coder;
@@ -33,6 +36,7 @@ import org.slf4j.LoggerFactory;
* Listens for messages received on a topic, in JSON format, decodes them into a
* {@link StandardCoderObject}, and then offers the objects to the subclass.
*/
+@NoArgsConstructor(access = AccessLevel.PROTECTED)
public abstract class JsonListener implements TopicListener {
private static final Logger logger = LoggerFactory.getLogger(JsonListener.class);
@@ -41,13 +45,6 @@ public abstract class JsonListener implements TopicListener {
*/
private static final Coder coder = new StandardCoder();
- /**
- * Constructs the object.
- */
- public JsonListener() {
- super();
- }
-
@Override
public void onTopicEvent(CommInfrastructure infra, String topic, String event) {
// decode from JSON into a standard object
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/MessageTypeDispatcher.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/MessageTypeDispatcher.java
index 195a7eec..41f9abdb 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/MessageTypeDispatcher.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/MessageTypeDispatcher.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. 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.
@@ -36,7 +36,7 @@ public class MessageTypeDispatcher extends JsonListener {
/**
* Name of the message field, which may be hierarchical.
*/
- private final String[] messageFieldNames;
+ private final Object[] messageFieldNames;
/**
* Name of the message field, joined with "." - for logging.
@@ -80,7 +80,7 @@ public class MessageTypeDispatcher extends JsonListener {
@Override
public void onTopicEvent(CommInfrastructure infra, String topic, StandardCoderObject sco) {
// extract the message type
- final String type = sco.getString(messageFieldNames);
+ final var type = sco.getString(messageFieldNames);
if (type == null) {
logger.warn("unable to extract {}: {}", fullMessageFieldName, sco);
return;
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcher.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcher.java
index fcf9c9a9..e575e33b 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcher.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcher.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. 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.
@@ -43,7 +43,7 @@ public class RequestIdDispatcher<T> extends ScoListener<T> {
/**
* Name of the request id field, which may be hierarchical.
*/
- private final String[] requestIdFieldNames;
+ private final Object[] requestIdFieldNames;
/**
* Listeners for autonomous messages.
@@ -111,7 +111,7 @@ public class RequestIdDispatcher<T> extends ScoListener<T> {
public void onTopicEvent(CommInfrastructure infra, String topic, StandardCoderObject sco, T message) {
// extract the request id
- String reqid = sco.getString(requestIdFieldNames);
+ var reqid = sco.getString(requestIdFieldNames);
// dispatch the message
if (Strings.isNullOrEmpty(reqid)) {
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/ScoListener.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/ScoListener.java
index a3d33965..dc6ff12a 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/ScoListener.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/ScoListener.java
@@ -2,7 +2,8 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020 Bell Canada. 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.
@@ -20,6 +21,8 @@
package org.onap.policy.common.endpoints.listeners;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
@@ -34,6 +37,7 @@ import org.slf4j.LoggerFactory;
*
* @param <T> type of message/POJO this handles
*/
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
public abstract class ScoListener<T> {
private static final Logger logger = LoggerFactory.getLogger(ScoListener.class);
@@ -49,15 +53,6 @@ public abstract class ScoListener<T> {
private final Class<T> clazz;
/**
- * Constructs the object.
- *
- * @param clazz class of message this handles
- */
- public ScoListener(Class<T> clazz) {
- this.clazz = clazz;
- }
-
- /**
* Receives an event, translates it into the desired type of object, and passes it to
* the subclass.
*