aboutsummaryrefslogtreecommitdiffstats
path: root/policy-management/src/main/java/org
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-08-05 10:13:01 -0400
committerJim Hahn <jrh3@att.com>2021-08-05 11:18:36 -0400
commit1744dac574fb771301027be74c9257eb070125f7 (patch)
treeb35035a120a2fb5d99114091c89ed8dbfa57cd22 /policy-management/src/main/java/org
parent43cb6711bbc9b231e904ff3ef5266f0f0df3faec (diff)
Use lombok in drools-pdp
Updated policy-management thru policy-utils. Issue-ID: POLICY-3397 Change-Id: Ie9498fe912e8338ddc32a40774c3cb63d84f079a Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'policy-management/src/main/java/org')
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java4
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java65
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/persistence/SystemPersistenceConstants.java9
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java75
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderConstants.java9
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolDecoder.java11
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolEncoder.java13
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolParams.java121
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/GenericEventProtocolCoder.java22
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/GsonProtocolCoderToolset.java48
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java13
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/MultiplexorEventProtocolCoder.java14
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolset.java76
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/TopicCoderFilterConfiguration.java186
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java38
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java39
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java43
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java42
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/Main.java15
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/PolicyControllerConstants.java11
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineConstants.java7
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java9
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java76
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/internal/LockManager.java20
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/internal/SimpleLockManager.java4
25 files changed, 195 insertions, 775 deletions
diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java
index 5e6e469f..d7d387b8 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java
@@ -286,14 +286,14 @@ public class MavenDroolsController implements DroolsController {
.eventClass(potentialCodedClass)
.protocolFilter(protocolFilter)
.customGsonCoder(customGsonCoder)
- .modelClassLoaderHash(this.policyContainer.getClassLoader().hashCode()));
+ .modelClassLoaderHash(this.policyContainer.getClassLoader().hashCode()).build());
} else {
getCoderManager().addEncoder(
EventProtocolParams.builder().groupId(this.getGroupId())
.artifactId(this.getArtifactId()).topic(topic)
.eventClass(potentialCodedClass).protocolFilter(protocolFilter)
.customGsonCoder(customGsonCoder)
- .modelClassLoaderHash(this.policyContainer.getClassLoader().hashCode()));
+ .modelClassLoaderHash(this.policyContainer.getClassLoader().hashCode()).build());
}
}
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java b/policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java
index 02a1a81b..d35f5469 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -33,6 +33,8 @@ import java.util.Comparator;
import java.util.List;
import java.util.Properties;
import java.util.function.BiPredicate;
+import lombok.Getter;
+import lombok.ToString;
import org.onap.policy.drools.properties.DroolsPropertyConstants;
import org.onap.policy.drools.utils.PropertyUtil;
import org.slf4j.Logger;
@@ -41,6 +43,8 @@ import org.slf4j.LoggerFactory;
/**
* Properties based Persistence.
*/
+@Getter
+@ToString
public class FileSystemPersistence implements SystemPersistence {
/**
@@ -104,14 +108,15 @@ public class FileSystemPersistence implements SystemPersistence {
public static final String SYSTEM_PROPERTIES_FILE_SUFFIX = SYSTEM_PROPERTIES_SUFFIX + PROPERTIES_FILE_EXTENSION;
/**
- * Configuration directory.
+ * Logger.
*/
- protected Path configurationDirectory = Paths.get(SystemPersistenceConstants.DEFAULT_CONFIGURATION_DIR);
+ private static final Logger logger = LoggerFactory.getLogger(FileSystemPersistence.class);
/**
- * Logger.
+ * Configuration directory.
*/
- private static final Logger logger = LoggerFactory.getLogger(FileSystemPersistence.class);
+ protected Path configurationPath = Paths.get(SystemPersistenceConstants.DEFAULT_CONFIGURATION_DIR);
+
@Override
public void setConfigurationDir(String configDir) {
@@ -119,11 +124,11 @@ public class FileSystemPersistence implements SystemPersistence {
if (tempConfigDir == null) {
tempConfigDir = SystemPersistenceConstants.DEFAULT_CONFIGURATION_DIR;
- this.configurationDirectory = Paths.get(SystemPersistenceConstants.DEFAULT_CONFIGURATION_DIR);
+ this.configurationPath = Paths.get(SystemPersistenceConstants.DEFAULT_CONFIGURATION_DIR);
}
if (!tempConfigDir.equals(SystemPersistenceConstants.DEFAULT_CONFIGURATION_DIR)) {
- this.configurationDirectory = Paths.get(tempConfigDir);
+ this.configurationPath = Paths.get(tempConfigDir);
}
setConfigurationDir();
@@ -131,25 +136,20 @@ public class FileSystemPersistence implements SystemPersistence {
@Override
public void setConfigurationDir() {
- if (Files.notExists(this.configurationDirectory)) {
+ if (Files.notExists(this.configurationPath)) {
try {
- Files.createDirectories(this.configurationDirectory);
+ Files.createDirectories(this.configurationPath);
} catch (final IOException e) {
- throw new IllegalStateException("cannot create " + this.configurationDirectory, e);
+ throw new IllegalStateException("cannot create " + this.configurationPath, e);
}
}
- if (!Files.isDirectory(this.configurationDirectory)) {
+ if (!Files.isDirectory(this.configurationPath)) {
throw new IllegalStateException(
- "config directory: " + this.configurationDirectory + " is not a directory");
+ "config directory: " + this.configurationPath + " is not a directory");
}
}
- @Override
- public Path getConfigurationPath() {
- return this.configurationDirectory;
- }
-
protected Properties getProperties(Path propertiesPath) {
if (!Files.exists(propertiesPath)) {
throw new IllegalArgumentException("properties for " + propertiesPath.toString() + " are not persisted.");
@@ -168,7 +168,7 @@ public class FileSystemPersistence implements SystemPersistence {
throw new IllegalArgumentException("properties name must be provided");
}
- Path propertiesPath = Paths.get(this.configurationDirectory.toString());
+ var propertiesPath = Paths.get(this.configurationPath.toString());
if (name.endsWith(PROPERTIES_FILE_EXTENSION) || name.endsWith(ENV_FILE_EXTENSION)) {
propertiesPath = propertiesPath.resolve(name);
} else {
@@ -196,7 +196,7 @@ public class FileSystemPersistence implements SystemPersistence {
private void addToPropertiesList(File file, List<Properties> properties,
BiPredicate<String, Properties> preCondition) {
try {
- Properties proposedProps = getProperties(file.getName());
+ var proposedProps = getProperties(file.getName());
if (preCondition.test(file.getName(), proposedProps)) {
properties.add(proposedProps);
}
@@ -212,7 +212,7 @@ public class FileSystemPersistence implements SystemPersistence {
throw new IllegalArgumentException("environment name must be provided");
}
- return this.getProperties(Paths.get(this.configurationDirectory.toString(), name + ENV_FILE_SUFFIX));
+ return this.getProperties(Paths.get(this.configurationPath.toString(), name + ENV_FILE_SUFFIX));
}
@Override
@@ -276,7 +276,7 @@ public class FileSystemPersistence implements SystemPersistence {
}
private boolean testControllerName(String controllerFilename, Properties controllerProperties) {
- String controllerName = controllerFilename
+ var controllerName = controllerFilename
.substring(0, controllerFilename.length() - PROPERTIES_FILE_CONTROLLER_SUFFIX.length());
String controllerPropName = controllerProperties.getProperty(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME);
if (controllerPropName == null) {
@@ -311,11 +311,11 @@ public class FileSystemPersistence implements SystemPersistence {
}
protected boolean backup(String name, String fileSuffix) {
- Path path = Paths.get(this.configurationDirectory.toString(), name + fileSuffix);
+ var path = Paths.get(this.configurationPath.toString(), name + fileSuffix);
if (Files.exists(path)) {
try {
logger.info("{}: there is an existing configuration file @ {} ", this, path);
- Path bakPath = Paths.get(this.configurationDirectory.toString(),
+ var bakPath = Paths.get(this.configurationPath.toString(),
name + fileSuffix + FILE_BACKUP_SUFFIX);
Files.copy(path, bakPath, StandardCopyOption.REPLACE_EXISTING);
} catch (Exception e) {
@@ -351,10 +351,10 @@ public class FileSystemPersistence implements SystemPersistence {
}
private boolean store(String name, Properties properties, String fileSuffix) {
- Path path = Paths.get(this.configurationDirectory.toString(), name + fileSuffix);
+ var path = Paths.get(this.configurationPath.toString(), name + fileSuffix);
if (Files.exists(path)) {
try {
- Properties oldProperties = PropertyUtil.getProperties(path.toFile());
+ var oldProperties = PropertyUtil.getProperties(path.toFile());
if (oldProperties.equals(properties)) {
logger.info("{}: noop: a properties file with the same contents exists for controller {}.", this,
name);
@@ -368,8 +368,8 @@ public class FileSystemPersistence implements SystemPersistence {
}
}
- File file = path.toFile();
- try (FileWriter writer = new FileWriter(file)) {
+ var file = path.toFile();
+ try (var writer = new FileWriter(file)) {
properties.store(writer, "Machine created Policy Controller Configuration");
} catch (Exception e) {
logger.warn("{}: {} cannot be saved", this, name, e);
@@ -408,11 +408,11 @@ public class FileSystemPersistence implements SystemPersistence {
}
protected boolean delete(String name, String fileSuffix) {
- Path path = Paths.get(this.configurationDirectory.toString(), name + fileSuffix);
+ var path = Paths.get(this.configurationPath.toString(), name + fileSuffix);
if (Files.exists(path)) {
try {
- Path bakPath = Paths.get(this.configurationDirectory.toString(),
+ var bakPath = Paths.get(this.configurationPath.toString(),
name + fileSuffix + FILE_BACKUP_SUFFIX);
Files.move(path, bakPath, StandardCopyOption.REPLACE_EXISTING);
} catch (final Exception e) {
@@ -428,7 +428,7 @@ public class FileSystemPersistence implements SystemPersistence {
* provides a list of files sorted by name in ascending order in the configuration directory.
*/
private File[] sortedListFiles() {
- File[] dirFiles = this.configurationDirectory.toFile().listFiles();
+ File[] dirFiles = this.configurationPath.toFile().listFiles();
if (dirFiles != null) {
Arrays.sort(dirFiles, Comparator.comparing(File::getName));
} else {
@@ -436,9 +436,4 @@ public class FileSystemPersistence implements SystemPersistence {
}
return dirFiles;
}
-
- @Override
- public String toString() {
- return "FileSystemPersistence [configurationDirectory=" + this.configurationDirectory + "]";
- }
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/persistence/SystemPersistenceConstants.java b/policy-management/src/main/java/org/onap/policy/drools/persistence/SystemPersistenceConstants.java
index 0b46fb02..ba6c5e71 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/persistence/SystemPersistenceConstants.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/persistence/SystemPersistenceConstants.java
@@ -20,9 +20,12 @@
package org.onap.policy.drools.persistence;
+import lombok.AccessLevel;
import lombok.Getter;
+import lombok.NoArgsConstructor;
-public class SystemPersistenceConstants {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class SystemPersistenceConstants {
/**
* configuration directory.
*/
@@ -34,8 +37,4 @@ public class SystemPersistenceConstants {
*/
@Getter
private static final SystemPersistence manager = new FileSystemPersistence();
-
- private SystemPersistenceConstants() {
- // do nothing
- }
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java
index 7e268591..278ea41b 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java
@@ -22,6 +22,10 @@
package org.onap.policy.drools.protocol.coders;
import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
import org.onap.policy.drools.controller.DroolsController;
/**
@@ -29,6 +33,10 @@ import org.onap.policy.drools.controller.DroolsController;
*/
public interface EventProtocolCoder {
+ @Getter
+ @Setter
+ @ToString
+ @AllArgsConstructor
public static class CoderFilters {
/**
@@ -45,73 +53,6 @@ public interface EventProtocolCoder {
* classloader hash.
*/
protected int modelClassLoaderHash;
-
- /**
- * constructor.
- *
- * @param codedClass coder class
- * @param filter filters to apply
- */
- public CoderFilters(String codedClass, JsonProtocolFilter filter, int modelClassLoaderHash) {
- this.factClass = codedClass;
- this.filter = filter;
- this.modelClassLoaderHash = modelClassLoaderHash;
- }
-
- /**
- * Get coded class.
- *
- * @return the codedClass
- */
- public String getCodedClass() {
- return factClass;
- }
-
- /**
- * Set coded class.
- *
- * @param codedClass the decodedClass to set
- */
- public void setCodedClass(String codedClass) {
- this.factClass = codedClass;
- }
-
- /**
- * Get filter.
- *
- * @return the filter
- */
- public JsonProtocolFilter getFilter() {
- return filter;
- }
-
- /**
- * Set filter.
- *
- * @param filter the filter to set
- */
- public void setFilter(JsonProtocolFilter filter) {
- this.filter = filter;
- }
-
- public int getModelClassLoaderHash() {
- return modelClassLoaderHash;
- }
-
- public void setFromClassLoaderHash(int fromClassLoaderHash) {
- this.modelClassLoaderHash = fromClassLoaderHash;
- }
-
- @Override
- public String toString() {
- return "CoderFilters [factClass="
- + factClass
- + ", filter="
- + filter
- + ", modelClassLoaderHash="
- + modelClassLoaderHash
- + "]";
- }
}
/**
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderConstants.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderConstants.java
index 45dc39e4..160da9fe 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderConstants.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderConstants.java
@@ -21,17 +21,16 @@
package org.onap.policy.drools.protocol.coders;
+import lombok.AccessLevel;
import lombok.Getter;
+import lombok.NoArgsConstructor;
-public class EventProtocolCoderConstants {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class EventProtocolCoderConstants {
/**
* singleton reference to the global event protocol coder.
*/
@Getter
private static final EventProtocolCoder manager = new MultiplexorEventProtocolCoder();
-
- private EventProtocolCoderConstants() {
- // do nothing
- }
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolDecoder.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolDecoder.java
index 6bb3a623..cbedbba0 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolDecoder.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolDecoder.java
@@ -20,14 +20,9 @@
package org.onap.policy.drools.protocol.coders;
-class EventProtocolDecoder extends GenericEventProtocolCoder {
+import lombok.ToString;
- public EventProtocolDecoder() {
- super();
- }
+@ToString(callSuper = true)
+class EventProtocolDecoder extends GenericEventProtocolCoder {
- @Override
- public String toString() {
- return "EventProtocolDecoder [toString()=" + super.toString() + "]";
- }
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolEncoder.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolEncoder.java
index 461c66a8..2f81e53d 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolEncoder.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolEncoder.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.
@@ -20,14 +20,9 @@
package org.onap.policy.drools.protocol.coders;
-class EventProtocolEncoder extends GenericEventProtocolCoder {
+import lombok.ToString;
- public EventProtocolEncoder() {
- super();
- }
+@ToString(callSuper = true)
+class EventProtocolEncoder extends GenericEventProtocolCoder {
- @Override
- public String toString() {
- return "EventProtocolEncoder [toString()=" + super.toString() + "]";
- }
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolParams.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolParams.java
index 810562cd..c5fdcc6a 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolParams.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolParams.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,8 +21,11 @@
package org.onap.policy.drools.protocol.coders;
-import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration.CustomCoder;
+import lombok.Builder;
+import lombok.Getter;
+@Getter
+@Builder
public class EventProtocolParams {
private String groupId;
private String artifactId;
@@ -31,118 +34,4 @@ public class EventProtocolParams {
private JsonProtocolFilter protocolFilter;
private TopicCoderFilterConfiguration.CustomGsonCoder customGsonCoder;
private int modelClassLoaderHash;
-
- public String getGroupId() {
- return groupId;
- }
-
- public String getArtifactId() {
- return artifactId;
- }
-
- public String getTopic() {
- return topic;
- }
-
- public String getEventClass() {
- return eventClass;
- }
-
- public JsonProtocolFilter getProtocolFilter() {
- return protocolFilter;
- }
-
- public TopicCoderFilterConfiguration.CustomGsonCoder getCustomGsonCoder() {
- return customGsonCoder;
- }
-
- public int getModelClassLoaderHash() {
- return modelClassLoaderHash;
- }
-
- public static EventProtocolParams builder() {
- return new EventProtocolParams();
- }
-
- /**
- * Setter method.
- *
- * @param groupId of the controller
- * @return EventProtocolParams
- */
- public EventProtocolParams groupId(String groupId) {
- this.groupId = groupId;
- return this;
- }
-
- /**
- * Setter method.
- *
- * @param artifactId of the controller
- * @return EventProtocolParams
- */
- public EventProtocolParams artifactId(String artifactId) {
- this.artifactId = artifactId;
- return this;
- }
-
- /**
- * Setter method.
- *
- * @param topic the topic
- * @return EventProtocolParams
- */
- public EventProtocolParams topic(String topic) {
- this.topic = topic;
- return this;
- }
-
- /**
- * Setter method.
- *
- * @param eventClass the event class
- * @return EventProtocolParams
- */
- public EventProtocolParams eventClass(String eventClass) {
- this.eventClass = eventClass;
- return this;
- }
-
- /**
- * Setter method.
- *
- * @param protocolFilter filters to selectively choose a particular decoder
- * when there are multiples
- * @return EventProtocolParams
- */
- public EventProtocolParams protocolFilter(JsonProtocolFilter protocolFilter) {
- this.protocolFilter = protocolFilter;
- return this;
- }
-
- /**
- * Setter method.
- *
- * @param customGsonCoder custom gscon coder
- * @return EventProtocolParams
- */
- public EventProtocolParams customGsonCoder(
- TopicCoderFilterConfiguration.CustomGsonCoder customGsonCoder) {
- this.customGsonCoder = customGsonCoder;
- return this;
- }
-
- /**
- * Setter method.
- * @param modelClassLoaderHash integer representing model hash
- * @return EventProtocolParams
- */
- public EventProtocolParams modelClassLoaderHash(int modelClassLoaderHash) {
- this.modelClassLoaderHash = modelClassLoaderHash;
- return this;
- }
-
- public CustomCoder getCustomCoder() {
- return this.customGsonCoder;
- }
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/GenericEventProtocolCoder.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/GenericEventProtocolCoder.java
index 5faf8a86..8c734d52 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/GenericEventProtocolCoder.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/GenericEventProtocolCoder.java
@@ -25,6 +25,9 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
import org.onap.policy.drools.controller.DroolsController;
import org.onap.policy.drools.controller.DroolsControllerConstants;
import org.onap.policy.drools.protocol.coders.EventProtocolCoder.CoderFilters;
@@ -35,6 +38,8 @@ import org.slf4j.LoggerFactory;
* This protocol Coder that does its best attempt to decode/encode, selecting the best class and best fitted json
* parsing tools.
*/
+@ToString
+@NoArgsConstructor(access = AccessLevel.PROTECTED)
abstract class GenericEventProtocolCoder {
private static final String INVALID_ARTIFACT_ID_MSG = "Invalid artifact id";
private static final String INVALID_GROUP_ID_MSG = "Invalid group id";
@@ -58,10 +63,6 @@ abstract class GenericEventProtocolCoder {
protected final HashMap<String, List<ProtocolCoderToolset>>
reverseCoders = new HashMap<>();
- GenericEventProtocolCoder() {
- super();
- }
-
/**
* Index a new coder.
*/
@@ -213,7 +214,7 @@ abstract class GenericEventProtocolCoder {
logger.info("{}: removed toolset for {}: {}", this, key, coderToolset);
for (CoderFilters codeFilter : coderToolset.getCoders()) {
- String className = codeFilter.getCodedClass();
+ String className = codeFilter.getFactClass();
String reverseKey = this.reverseCodersKey(topic, className);
removeReverseCoder(key, reverseKey);
}
@@ -483,7 +484,7 @@ abstract class GenericEventProtocolCoder {
String artifactId = encoderSet.getArtifactId();
List<CoderFilters> coderFilters = encoderSet.getCoders();
for (CoderFilters coder : coderFilters) {
- if (coder.getCodedClass().equals(encodedClass.getClass().getName())) {
+ if (coder.getFactClass().equals(encodedClass.getClass().getName())) {
var droolsController =
DroolsControllerConstants.getFactory().get(groupId, artifactId, "");
if (droolsController.ownsCoder(
@@ -719,13 +720,4 @@ abstract class GenericEventProtocolCoder {
}
return droolsControllers;
}
-
- @Override
- public String toString() {
- return "GenericEventProtocolCoder [coders="
- + coders.keySet()
- + ", reverseCoders="
- + reverseCoders.keySet()
- + "]";
- }
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/GsonProtocolCoderToolset.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/GsonProtocolCoderToolset.java
index 637e0c14..f3525e90 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/GsonProtocolCoderToolset.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/GsonProtocolCoderToolset.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 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.
@@ -28,14 +28,12 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.time.Instant;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
+import lombok.ToString;
import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
-import org.onap.policy.drools.controller.DroolsController;
import org.onap.policy.drools.controller.DroolsControllerConstants;
import org.onap.policy.drools.protocol.coders.EventProtocolCoder.CoderFilters;
import org.slf4j.Logger;
@@ -44,6 +42,7 @@ import org.slf4j.LoggerFactory;
/**
* Tools used for encoding/decoding using GSON.
*/
+@ToString(callSuper = true)
class GsonProtocolCoderToolset extends ProtocolCoderToolset {
private static final String CANNOT_FETCH_CLASS = "{}: cannot fetch application class {}";
private static final String FETCH_CLASS_EX_MSG = "cannot fetch application class ";
@@ -151,7 +150,7 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
@Override
public Object decode(String json) {
- final DroolsController droolsController =
+ final var droolsController =
DroolsControllerConstants.getFactory().get(this.groupId, this.artifactId, "");
if (droolsController == null) {
logger.warn("{}: no drools-controller to process {}", this, json);
@@ -166,31 +165,31 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
Class<?> decoderClass;
try {
- decoderClass = droolsController.fetchModelClass(decoderFilter.getCodedClass());
+ decoderClass = droolsController.fetchModelClass(decoderFilter.getFactClass());
if (decoderClass == null) {
- logger.warn(CANNOT_FETCH_CLASS, this, decoderFilter.getCodedClass());
+ logger.warn(CANNOT_FETCH_CLASS, this, decoderFilter.getFactClass());
throw new IllegalStateException(
- FETCH_CLASS_EX_MSG + decoderFilter.getCodedClass());
+ FETCH_CLASS_EX_MSG + decoderFilter.getFactClass());
}
} catch (final Exception e) {
- logger.warn(CANNOT_FETCH_CLASS, this, decoderFilter.getCodedClass());
+ logger.warn(CANNOT_FETCH_CLASS, this, decoderFilter.getFactClass());
throw new UnsupportedOperationException(
- FETCH_CLASS_EX_MSG + decoderFilter.getCodedClass(), e);
+ FETCH_CLASS_EX_MSG + decoderFilter.getFactClass(), e);
}
if (this.customCoder != null) {
try {
- final Class<?> gsonClassContainer =
+ final var gsonClassContainer =
droolsController.fetchModelClass(this.customCoder.getClassContainer());
- final Field gsonField = gsonClassContainer.getField(this.customCoder.staticCoderField);
- final Object gsonObject = gsonField.get(null);
- final Method fromJsonMethod = gsonObject.getClass().getDeclaredMethod("fromJson",
+ final var gsonField = gsonClassContainer.getField(this.customCoder.staticCoderField);
+ final var gsonObject = gsonField.get(null);
+ final var fromJsonMethod = gsonObject.getClass().getDeclaredMethod("fromJson",
String.class, Class.class);
return fromJsonMethod.invoke(gsonObject, json, decoderClass);
} catch (final Exception e) {
- logger.warn(CANNOT_FETCH_CLASS, this, decoderFilter.getCodedClass());
+ logger.warn(CANNOT_FETCH_CLASS, this, decoderFilter.getFactClass());
throw new UnsupportedOperationException(
- FETCH_CLASS_EX_MSG + decoderFilter.getCodedClass(), e);
+ FETCH_CLASS_EX_MSG + decoderFilter.getFactClass(), e);
}
} else {
try {
@@ -198,7 +197,7 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
} catch (final Exception e) {
logger.warn("{} cannot decode {} into {}", this, json, decoderClass.getName());
throw new UnsupportedOperationException(
- "cannont decode into " + decoderFilter.getCodedClass(), e);
+ "cannont decode into " + decoderFilter.getFactClass(), e);
}
}
}
@@ -211,13 +210,13 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
if (this.customCoder != null) {
try {
- final DroolsController droolsController =
+ final var droolsController =
DroolsControllerConstants.getFactory().get(this.groupId, this.artifactId, null);
final Class<?> gsonClassContainer =
droolsController.fetchModelClass(this.customCoder.getClassContainer());
- final Field gsonField = gsonClassContainer.getField(this.customCoder.staticCoderField);
- final Object gsonObject = gsonField.get(null);
- final Method toJsonMethod =
+ final var gsonField = gsonClassContainer.getField(this.customCoder.staticCoderField);
+ final var gsonObject = gsonField.get(null);
+ final var toJsonMethod =
gsonObject.getClass().getDeclaredMethod("toJson", Object.class);
return (String) toJsonMethod.invoke(gsonObject, event);
} catch (final Exception e) {
@@ -233,11 +232,4 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
}
}
}
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("GsonProtocolCoderToolset [toString()=").append(super.toString()).append("]");
- return builder.toString();
- }
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java
index 2ccc010f..430f4ffe 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -26,10 +26,12 @@ import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.Option;
import java.util.ArrayList;
import java.util.List;
+import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** JSON Protocol Filter. */
+@Getter
public class JsonProtocolFilter {
/** Default filter to match anything. */
@@ -60,15 +62,6 @@ public class JsonProtocolFilter {
}
/**
- * Gets the filter expression rule.
- *
- * @return the filter expression associated with this JsonProtocolFilter
- */
- public String getRule() {
- return this.rule;
- }
-
- /**
* Sets the filter expression rule.
*
* @param rule the JsonPath expression rule
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/MultiplexorEventProtocolCoder.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/MultiplexorEventProtocolCoder.java
index d341024a..3fea6821 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/MultiplexorEventProtocolCoder.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/MultiplexorEventProtocolCoder.java
@@ -22,6 +22,7 @@ package org.onap.policy.drools.protocol.coders;
import java.util.ArrayList;
import java.util.List;
+import lombok.ToString;
import org.onap.policy.drools.controller.DroolsController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,6 +31,7 @@ import org.slf4j.LoggerFactory;
* Protocol Coder that does its best attempt to decode/encode, selecting the best class and best fitted json parsing
* tools.
*/
+@ToString
class MultiplexorEventProtocolCoder implements EventProtocolCoder {
/**
@@ -281,16 +283,4 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
public List<DroolsController> getDroolsControllers(String topic, Object encodedClass) {
return this.encoders.getDroolsControllers(topic, encodedClass);
}
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String toString() {
- return "MultiplexorEventProtocolCoder [decoders="
- + decoders
- + ", encoders="
- + encoders
- + "]";
- }
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolset.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolset.java
index 7cf3a2f3..493095b7 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolset.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolset.java
@@ -24,6 +24,9 @@ package org.onap.policy.drools.protocol.coders;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
import org.onap.policy.drools.protocol.coders.EventProtocolCoder.CoderFilters;
import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration.CustomCoder;
import org.slf4j.Logger;
@@ -32,6 +35,8 @@ import org.slf4j.LoggerFactory;
/**
* Protocol Coding/Decoding Toolset.
*/
+@Getter
+@ToString
public abstract class ProtocolCoderToolset {
/**
@@ -67,6 +72,7 @@ public abstract class ProtocolCoderToolset {
/**
* custom coder.
*/
+ @Setter
protected CustomCoder customCoder;
/**
@@ -90,7 +96,7 @@ public abstract class ProtocolCoderToolset {
eventProtocolParams.getEventClass(),
eventProtocolParams.getProtocolFilter(),
eventProtocolParams.getModelClassLoaderHash()));
- this.customCoder = eventProtocolParams.getCustomCoder();
+ this.customCoder = eventProtocolParams.getCustomGsonCoder();
}
/**
@@ -133,9 +139,9 @@ public abstract class ProtocolCoderToolset {
}
for (final CoderFilters coder : this.coders) {
- if (coder.getCodedClass().equals(eventClass)) {
+ if (coder.getFactClass().equals(eventClass)) {
coder.setFilter(filter);
- coder.setFromClassLoaderHash(modelClassLoaderHash);
+ coder.setModelClassLoaderHash(modelClassLoaderHash);
return;
}
}
@@ -163,60 +169,6 @@ public abstract class ProtocolCoderToolset {
}
/**
- * gets the topic.
- *
- * @return the topic
- */
- public String getTopic() {
- return this.topic;
- }
-
- /**
- * gets the controller id.
- *
- * @return the controller id
- */
- public String getControllerId() {
- return this.controllerId;
- }
-
- /**
- * Get group id.
- *
- * @return the groupId
- */
- public String getGroupId() {
- return this.groupId;
- }
-
- /**
- * Get artifact id.
- *
- * @return the artifactId
- */
- public String getArtifactId() {
- return this.artifactId;
- }
-
- /**
- * Get custom coder.
- *
- * @return the customCoder
- */
- public CustomCoder getCustomCoder() {
- return this.customCoder;
- }
-
- /**
- * Set custom coder.
- *
- * @param customCoder the customCoder to set.
- */
- public void setCustomCoder(CustomCoder customCoder) {
- this.customCoder = customCoder;
- }
-
- /**
* performs filtering on a json string.
*
* @param json json string
@@ -274,14 +226,4 @@ public abstract class ProtocolCoderToolset {
* @throws UnsupportedOperationException if parsing into POJO is not possible
*/
public abstract String encode(Object event);
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("ProtocolCoderToolset [topic=").append(this.topic).append(", controllerId=")
- .append(this.controllerId).append(", groupId=").append(this.groupId).append(", artifactId=")
- .append(this.artifactId).append(", coders=").append(this.coders)
- .append(", customCoder=").append(this.customCoder).append("]");
- return builder.toString();
- }
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/TopicCoderFilterConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/TopicCoderFilterConfiguration.java
index 9da48521..4dd132b9 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/TopicCoderFilterConfiguration.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/TopicCoderFilterConfiguration.java
@@ -21,15 +21,24 @@
package org.onap.policy.drools.protocol.coders;
import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+@Getter
+@ToString
public class TopicCoderFilterConfiguration {
/**
* Custom coder, contains class and static field to access parser that the controller desires to
* use instead of the framework provided parser.
*/
+ @Getter
+ @Setter
+ @ToString
public abstract static class CustomCoder {
- protected String className;
+ protected String classContainer;
protected String staticCoderField;
/**
@@ -44,8 +53,8 @@ public class TopicCoderFilterConfiguration {
protected CustomCoder(String rawCustomCoder) {
if (rawCustomCoder != null && !rawCustomCoder.isEmpty()) {
- this.className = rawCustomCoder.substring(0, rawCustomCoder.indexOf(','));
- if (this.className == null || this.className.isEmpty()) {
+ this.classContainer = rawCustomCoder.substring(0, rawCustomCoder.indexOf(','));
+ if (this.classContainer == null || this.classContainer.isEmpty()) {
throw new IllegalArgumentException(
"No classname to create CustomCoder cannot be created");
}
@@ -53,7 +62,7 @@ public class TopicCoderFilterConfiguration {
this.staticCoderField = rawCustomCoder.substring(rawCustomCoder.indexOf(',') + 1);
if (this.staticCoderField == null || this.staticCoderField.isEmpty()) {
throw new IllegalArgumentException(
- "No staticCoderField to create CustomCoder cannot be created for class " + className);
+ "No staticCoderField to create CustomCoder cannot be created for class " + classContainer);
}
}
}
@@ -74,59 +83,12 @@ public class TopicCoderFilterConfiguration {
"No staticCoderField to create CustomCoder cannot be created for class " + className);
}
- this.className = className;
+ this.classContainer = className;
this.staticCoderField = staticCoderField;
}
-
- /**
- * Get class container.
- *
- * @return the className
- **/
- public String getClassContainer() {
- return className;
- }
-
- /**
- * Set class container.
- *
- * @param className the className to set
- **/
- public void setClassContainer(String className) {
- this.className = className;
- }
-
- /**
- * Get static coder field.
- *
- * @return the staticCoderField
- **/
- public String getStaticCoderField() {
- return staticCoderField;
- }
-
- /**
- * Set static coder field.
- *
- * @param staticCoderField the staticGson to set
- **/
- public void setStaticCoderField(String staticCoderField) {
- this.staticCoderField = staticCoderField;
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder
- .append("CustomCoder [className=")
- .append(className)
- .append(", staticCoderField=")
- .append(staticCoderField)
- .append("]");
- return builder.toString();
- }
}
+ @ToString(callSuper = true)
public static class CustomGsonCoder extends CustomCoder {
public CustomGsonCoder(String className, String staticCoderField) {
@@ -136,19 +98,16 @@ public class TopicCoderFilterConfiguration {
public CustomGsonCoder(String customGson) {
super(customGson);
}
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("CustomGsonCoder [toString()=").append(super.toString()).append("]");
- return builder.toString();
- }
}
/**
* Coder/Decoder class and Filter container. The decoder class is potential, in order to be
* operational needs to be fetched from an available class loader.
*/
+ @Getter
+ @Setter
+ @ToString
+ @AllArgsConstructor
public static class PotentialCoderFilter {
/* decoder class (pending from being able to be fetched and found in some class loader) */
@@ -156,64 +115,6 @@ public class TopicCoderFilterConfiguration {
/* filters to apply to the selection of the decodedClass */
protected JsonProtocolFilter filter;
-
- /**
- * constructor.
- *
- * @param codedClass decoder class
- * @param filter filters to apply
- */
- public PotentialCoderFilter(String codedClass, JsonProtocolFilter filter) {
- this.codedClass = codedClass;
- this.filter = filter;
- }
-
- /**
- * Get coded class.
- *
- * @return the decodedClass
- **/
- public String getCodedClass() {
- return codedClass;
- }
-
- /** Set coded class.
- *
- * @param decodedClass the decodedClass to set
- **/
- public void setCodedClass(String decodedClass) {
- this.codedClass = decodedClass;
- }
-
- /**
- * Get filter.
- *
- * @return the filter
- **/
- public JsonProtocolFilter getFilter() {
- return filter;
- }
-
- /**
- * Set filter.
- *
- * @param filter the filter to set
- **/
- public void setFilter(JsonProtocolFilter filter) {
- this.filter = filter;
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder
- .append("PotentialCoderFilter [codedClass=")
- .append(codedClass)
- .append(", filter=")
- .append(filter)
- .append("]");
- return builder.toString();
- }
}
/* the source topic */
@@ -223,6 +124,7 @@ public class TopicCoderFilterConfiguration {
protected final List<PotentialCoderFilter> coderFilters;
/* custom gson coder that this controller prefers to use instead of the framework ones */
+ @Setter
protected CustomGsonCoder customGsonCoder;
/**
@@ -240,52 +142,4 @@ public class TopicCoderFilterConfiguration {
this.topic = topic;
this.customGsonCoder = customGsonCoder;
}
-
- /**
- * Get topic.
- * @return the topic
- **/
- public String getTopic() {
- return topic;
- }
-
- /** Get coder filters.
- *
- * @return the decoderFilters
- **/
- public List<PotentialCoderFilter> getCoderFilters() {
- return coderFilters;
- }
-
- /**
- * Get custom gson coder.
- *
- * @return the customGsonCoder
- **/
- public CustomGsonCoder getCustomGsonCoder() {
- return customGsonCoder;
- }
-
- /**
- * Set custom gson coder.
- *
- * @param customGsonCoder the customGsonCoder to set
- **/
- public void setCustomGsonCoder(CustomGsonCoder customGsonCoder) {
- this.customGsonCoder = customGsonCoder;
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder
- .append("TopicCoderFilterConfiguration [topic=")
- .append(topic)
- .append(", coderFilters=")
- .append(coderFilters)
- .append(", customGsonCoder=")
- .append(customGsonCoder)
- .append("]");
- return builder.toString();
- }
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java
index 663d6b83..9b19b8ac 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-management
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -22,9 +22,9 @@ package org.onap.policy.drools.protocol.configuration;
import java.util.HashMap;
import java.util.Map;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
import lombok.ToString;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.onap.policy.common.gson.annotation.GsonJsonAnyGetter;
import org.onap.policy.common.gson.annotation.GsonJsonAnySetter;
import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
@@ -36,6 +36,8 @@ import org.onap.policy.common.gson.annotation.GsonJsonProperty;
*
*/
@ToString
+@EqualsAndHashCode
+@NoArgsConstructor
public class ControllerConfiguration {
public static final String CONFIG_CONTROLLER_OPERATION_CREATE = "create";
@@ -43,6 +45,8 @@ public class ControllerConfiguration {
public static final String CONFIG_CONTROLLER_OPERATION_LOCK = "lock";
public static final String CONFIG_CONTROLLER_OPERATION_UNLOCK = "unlock";
+ protected static final Object NOT_FOUND_VALUE = new Object();
+
/**
* (Required).
*
@@ -66,15 +70,6 @@ public class ControllerConfiguration {
@GsonJsonIgnore
private Map<String, Object> additionalProperties = new HashMap<>();
- protected static final Object NOT_FOUND_VALUE = new Object();
-
- /**
- * No args constructor for use in serialization.
- *
- */
- public ControllerConfiguration() {
- // Empty
- }
/**
* Constructor.
@@ -260,25 +255,6 @@ public class ControllerConfiguration {
return this;
}
- @Override
- public int hashCode() {
- return new HashCodeBuilder().append(name).append(operation).append(drools).append(additionalProperties)
- .toHashCode();
- }
-
- @Override
- public boolean equals(Object other) {
- if (other == this) {
- return true;
- }
- if (!(other instanceof ControllerConfiguration)) {
- return false;
- }
- ControllerConfiguration rhs = ((ControllerConfiguration) other);
- return new EqualsBuilder().append(name, rhs.name).append(operation, rhs.operation).append(drools, rhs.drools)
- .append(additionalProperties, rhs.additionalProperties).isEquals();
- }
-
/**
* Call set name.
*
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java
index 1d4fc8d8..b39d0055 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-management
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -22,9 +22,9 @@ package org.onap.policy.drools.protocol.configuration;
import java.util.HashMap;
import java.util.Map;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
import lombok.ToString;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.onap.policy.common.gson.annotation.GsonJsonAnyGetter;
import org.onap.policy.common.gson.annotation.GsonJsonAnySetter;
import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
@@ -35,8 +35,12 @@ import org.onap.policy.common.gson.annotation.GsonJsonProperty;
*
*/
@ToString
+@EqualsAndHashCode
+@NoArgsConstructor
public class DroolsConfiguration {
+ protected static final Object NOT_FOUND_VALUE = new Object();
+
/**
* Maven Artifact ID
* (Required).
@@ -64,15 +68,6 @@ public class DroolsConfiguration {
@GsonJsonIgnore
private Map<String, Object> additionalProperties = new HashMap<>();
- protected static final Object NOT_FOUND_VALUE = new Object();
-
- /**
- * No args constructor for use in serialization.
- *
- */
- public DroolsConfiguration() {
- // Empty
- }
/**
* Constructor.
@@ -262,26 +257,6 @@ public class DroolsConfiguration {
return this;
}
- @Override
- public int hashCode() {
- return new HashCodeBuilder().append(artifactId).append(groupId).append(version).append(additionalProperties)
- .toHashCode();
- }
-
- @Override
- public boolean equals(Object other) {
- if (other == this) {
- return true;
- }
- if (!(other instanceof DroolsConfiguration)) {
- return false;
- }
- DroolsConfiguration rhs = ((DroolsConfiguration) other);
- return new EqualsBuilder().append(artifactId, rhs.artifactId)
- .append(groupId, rhs.groupId).append(version, rhs.version)
- .append(additionalProperties, rhs.additionalProperties).isEquals();
- }
-
/**
* Call set artifact id.
*
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java
index 6596408b..f3a422e7 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-management
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -24,9 +24,9 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
import lombok.ToString;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.onap.policy.common.gson.annotation.GsonJsonAnyGetter;
import org.onap.policy.common.gson.annotation.GsonJsonAnySetter;
import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
@@ -37,11 +37,15 @@ import org.onap.policy.common.gson.annotation.GsonJsonProperty;
* ENGINE-CONFIGURATION.
*/
@ToString
+@EqualsAndHashCode
+@NoArgsConstructor
public class PdpdConfiguration {
/** Controller Entity ID. */
public static final String CONFIG_ENTITY_CONTROLLER = "controller";
+ protected static final Object NOT_FOUND_VALUE = new Object();
+
/** Unique Transaction ID. This is an UUID. (Required) */
@GsonJsonProperty("requestID")
private String requestId;
@@ -53,12 +57,6 @@ public class PdpdConfiguration {
private List<ControllerConfiguration> controllers = new ArrayList<>();
@GsonJsonIgnore private Map<String, Object> additionalProperties = new HashMap<>();
- protected static final Object NOT_FOUND_VALUE = new Object();
-
- /** No args constructor for use in serialization. */
- public PdpdConfiguration() {
- // Empty
- }
/**
* Constructor.
@@ -231,33 +229,6 @@ public class PdpdConfiguration {
return this;
}
- @Override
- public int hashCode() {
- return new HashCodeBuilder()
- .append(requestId)
- .append(entity)
- .append(controllers)
- .append(additionalProperties)
- .toHashCode();
- }
-
- @Override
- public boolean equals(Object other) {
- if (other == this) {
- return true;
- }
- if (!(other instanceof PdpdConfiguration)) {
- return false;
- }
- PdpdConfiguration rhs = (PdpdConfiguration) other;
- return new EqualsBuilder()
- .append(requestId, rhs.requestId)
- .append(entity, rhs.entity)
- .append(controllers, rhs.controllers)
- .append(additionalProperties, rhs.additionalProperties)
- .isEquals();
- }
-
/**
* Call set request id.
*
diff --git a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
index 99b0ce6f..4374eb81 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
@@ -54,6 +54,10 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
import org.onap.policy.common.endpoints.event.comm.Topic;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
@@ -92,6 +96,7 @@ import org.slf4j.LoggerFactory;
produces = {MediaType.APPLICATION_JSON, YamlMessageBodyHandler.APPLICATION_YAML},
schemes = {SwaggerDefinition.Scheme.HTTP},
tags = {@Tag(name = "pdp-d-telemetry", description = "Drools PDP Telemetry Operations")})
+@ToString
public class RestManager {
private static final String OFFER_FAILED = "{}: cannot offer to topic {} because of {}";
@@ -2143,14 +2148,11 @@ public class RestManager {
* Helper classes for aggregation of results
*/
- @Override
- public String toString() {
- return "rest-telemetry-api []";
- }
-
/**
* Coding/Encoding Results Aggregation Helper class.
*/
+ @Getter
+ @Setter
public static class CodingResult {
/**
* serialized output.
@@ -2167,42 +2169,15 @@ public class RestManager {
* decoding result.
*/
private Boolean decoding;
-
- public String getJsonEncoding() {
- return jsonEncoding;
- }
-
- public void setJsonEncoding(String jsonEncoding) {
- this.jsonEncoding = jsonEncoding;
- }
-
- public Boolean getEncoding() {
- return encoding;
- }
-
- public void setEncoding(Boolean encoding) {
- this.encoding = encoding;
- }
-
- public Boolean getDecoding() {
- return decoding;
- }
-
- public void setDecoding(Boolean decoding) {
- this.decoding = decoding;
- }
}
/**
* Generic Error Reporting class.
*/
+ @AllArgsConstructor
public static class Error {
private String msg;
- public Error(String msg) {
- this.setError(msg);
- }
-
public String getError() {
return msg;
}
@@ -2212,4 +2187,3 @@ public class RestManager {
}
}
}
-
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/Main.java b/policy-management/src/main/java/org/onap/policy/drools/system/Main.java
index be0cb820..c28d4c96 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/Main.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/Main.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -21,6 +21,8 @@
package org.onap.policy.drools.system;
import java.util.Properties;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
@@ -39,16 +41,13 @@ import org.slf4j.LoggerFactory;
/**
* Programmatic entry point to the management layer.
*/
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class Main {
/**
* Symmetric Key to decode sensitive configuration data.
*/
protected static final String SYSTEM_SYMM_KEY = "engine.symm.key";
- /** constructor (hides public default one). */
- private Main() {
- }
-
/**
* main.
*
@@ -62,7 +61,7 @@ public class Main {
*/
/* start logger */
- Logger logger = LoggerFactory.getLogger(Main.class);
+ var logger = LoggerFactory.getLogger(Main.class);
/* system properties */
setSystemProperties();
@@ -191,7 +190,7 @@ public class Main {
.setTargetEntity("controller:" + controllerName)
.setTargetServiceName("start");
- final PolicyController controller =
+ final var controller =
PolicyEngineConstants.getManager().createPolicyController(controllerName, controllerProperties);
controller.start();
@@ -226,4 +225,4 @@ public class Main {
}
}
}
-} \ No newline at end of file
+}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyControllerConstants.java b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyControllerConstants.java
index 78d24129..c04cc0da 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyControllerConstants.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyControllerConstants.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.
@@ -20,17 +20,16 @@
package org.onap.policy.drools.system;
+import lombok.AccessLevel;
import lombok.Getter;
+import lombok.NoArgsConstructor;
-public class PolicyControllerConstants {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class PolicyControllerConstants {
/**
* Factory that tracks and manages Policy Controllers.
*/
@Getter
private static final PolicyControllerFactory factory = new IndexedPolicyControllerFactory();
-
- private PolicyControllerConstants() {
- // do nothing
- }
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineConstants.java b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineConstants.java
index 2173687a..23fc247e 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineConstants.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineConstants.java
@@ -20,9 +20,12 @@
package org.onap.policy.drools.system;
+import lombok.AccessLevel;
import lombok.Getter;
+import lombok.NoArgsConstructor;
import org.onap.policy.common.utils.network.NetworkUtil;
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class PolicyEngineConstants {
/**
@@ -50,8 +53,4 @@ public final class PolicyEngineConstants {
*/
@Getter
private static final PolicyEngine manager = new PolicyEngineManager();
-
- private PolicyEngineConstants() {
- // do nothing
- }
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java
index ec24286a..664f7c7f 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java
@@ -39,6 +39,7 @@ import java.util.stream.Stream;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NonNull;
+import lombok.ToString;
import org.apache.commons.lang3.StringUtils;
import org.onap.policy.common.endpoints.event.comm.Topic;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
@@ -88,6 +89,7 @@ import org.slf4j.LoggerFactory;
/**
* Policy Engine Manager Implementation.
*/
+@ToString(onlyExplicitlyIncluded = true)
class PolicyEngineManager implements PolicyEngine {
/**
* String literals.
@@ -110,12 +112,14 @@ class PolicyEngineManager implements PolicyEngine {
* Is the Policy Engine running.
*/
@Getter
+ @ToString.Include
private volatile boolean alive = false;
/**
* Is the engine locked.
*/
@Getter
+ @ToString.Include
private volatile boolean locked = false;
/**
@@ -1350,11 +1354,6 @@ class PolicyEngineManager implements PolicyEngine {
&& policyControllers.size() == configControllers.size());
}
- @Override
- public String toString() {
- return "PolicyEngineManager [alive=" + this.alive + ", locked=" + this.locked + "]";
- }
-
// these methods may be overridden by junit tests
protected List<PolicyEngineFeatureApi> getEngineProviders() {
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java b/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java
index 44b07a5c..06b3f4ea 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java
@@ -28,6 +28,8 @@ import java.util.List;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
+import lombok.Getter;
+import lombok.ToString;
import org.onap.policy.common.endpoints.event.comm.Topic;
import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
@@ -55,6 +57,7 @@ import org.slf4j.LoggerFactory;
* This implementation of the Policy Controller merely aggregates and tracks for management purposes
* all underlying resources that this controller depends upon.
*/
+@ToString(onlyExplicitlyIncluded = true)
public class AggregatedPolicyController implements PolicyController, TopicListener {
private static final String BEFORE_OFFER_FAILURE = "{}: feature {} before-offer failure because of {}";
@@ -69,17 +72,21 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
/**
* identifier for this policy controller.
*/
+ @Getter
+ @ToString.Include
private final String name;
/**
* Abstracted Event Sources List regardless communication technology.
*/
- protected final List<TopicSource> sources;
+ @Getter
+ protected final List<TopicSource> topicSources;
/**
* Abstracted Event Sinks List regardless communication technology.
*/
- protected final List<TopicSink> sinks;
+ @Getter
+ protected final List<TopicSink> topicSinks;
/**
* Mapping topics to sinks.
@@ -90,6 +97,8 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
/**
* Is this Policy Controller running (alive) ? reflects invocation of start()/stop() only.
*/
+ @Getter
+ @ToString.Include
private volatile boolean alive;
/**
@@ -97,11 +106,14 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
* are permitted, more specifically: start(), deliver() and onTopicEvent(). It does not affect
* the ability to stop the underlying drools infrastructure
*/
+ @Getter
+ @ToString.Include
private volatile boolean locked;
/**
* Policy Drools Controller.
*/
+ @ToString.Include
protected final AtomicReference<DroolsController> droolsController = new AtomicReference<>();
/**
@@ -135,8 +147,8 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
// Create/Reuse Readers/Writers for all event sources endpoints
- this.sources = getEndpointManager().addTopicSources(properties);
- this.sinks = getEndpointManager().addTopicSinks(properties);
+ this.topicSources = getEndpointManager().addTopicSources(properties);
+ this.topicSinks = getEndpointManager().addTopicSinks(properties);
initDrools(properties);
initSinks();
@@ -192,7 +204,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
protected void initDrools(Properties properties) {
try {
// Register with drools infrastructure
- this.droolsController.set(getDroolsFactory().build(properties, sources, sinks));
+ this.droolsController.set(getDroolsFactory().build(properties, topicSources, topicSinks));
} catch (Exception | LinkageError e) {
logger.error("{}: cannot init-drools", this);
throw new IllegalArgumentException(e);
@@ -206,7 +218,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
*/
private void initSinks() {
this.topic2Sinks.clear();
- for (TopicSink sink : sinks) {
+ for (TopicSink sink : topicSinks) {
this.topic2Sinks.put(sink.getTopic(), sink);
}
}
@@ -284,14 +296,6 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
* {@inheritDoc}.
*/
@Override
- public String getName() {
- return this.name;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public boolean start() {
logger.info("{}: start", this);
@@ -318,11 +322,11 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
// register for events
- for (TopicSource source : sources) {
+ for (TopicSource source : topicSources) {
source.register(this);
}
- for (TopicSink sink : sinks) {
+ for (TopicSink sink : topicSinks) {
try {
sink.start();
} catch (Exception e) {
@@ -364,7 +368,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
// 1. Stop registration
- for (TopicSource source : sources) {
+ for (TopicSource source : topicSources) {
source.unregister(this);
}
@@ -532,14 +536,6 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
* {@inheritDoc}.
*/
@Override
- public boolean isAlive() {
- return this.alive;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public boolean lock() {
logger.info("{}: lock", this);
@@ -608,30 +604,6 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
* {@inheritDoc}.
*/
@Override
- public boolean isLocked() {
- return this.locked;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public List<TopicSource> getTopicSources() {
- return this.sources;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public List<TopicSink> getTopicSinks() {
- return this.sinks;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public DroolsController getDrools() {
return this.droolsController.get();
}
@@ -646,12 +618,6 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
return this.properties;
}
- @Override
- public String toString() {
- return "AggregatedPolicyController [name=" + name + ", alive=" + alive
- + ", locked=" + locked + ", droolsController=" + droolsController + "]";
- }
-
// the following methods may be overridden by junit tests
protected SystemPersistence getPersistenceManager() {
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/internal/LockManager.java b/policy-management/src/main/java/org/onap/policy/drools/system/internal/LockManager.java
index 88037bbb..1683b0f5 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/internal/LockManager.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/internal/LockManager.java
@@ -24,6 +24,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import lombok.AccessLevel;
import lombok.Getter;
+import lombok.NoArgsConstructor;
import org.onap.policy.drools.core.lock.AlwaysFailLock;
import org.onap.policy.drools.core.lock.Lock;
import org.onap.policy.drools.core.lock.LockCallback;
@@ -45,6 +46,8 @@ import org.slf4j.LoggerFactory;
* will be added to the map once free() or extend() is invoked, provided there isn't
* already an entry.
*/
+@Getter
+@NoArgsConstructor(access = AccessLevel.PROTECTED)
public abstract class LockManager<T extends FeatureLockImpl> implements PolicyResourceLockManager {
private static final Logger logger = LoggerFactory.getLogger(LockManager.class);
@@ -68,18 +71,6 @@ public abstract class LockManager<T extends FeatureLockImpl> implements PolicyRe
private boolean locked = false;
- /**
- * Constructs the object.
- */
- protected LockManager() {
- super();
- }
-
- @Override
- public boolean isAlive() {
- return alive;
- }
-
@Override
public synchronized boolean start() {
if (alive) {
@@ -109,11 +100,6 @@ public abstract class LockManager<T extends FeatureLockImpl> implements PolicyRe
}
@Override
- public boolean isLocked() {
- return locked;
- }
-
- @Override
public synchronized boolean lock() {
if (locked) {
return false;
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/internal/SimpleLockManager.java b/policy-management/src/main/java/org/onap/policy/drools/system/internal/SimpleLockManager.java
index c2c921f5..855d18b7 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/internal/SimpleLockManager.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/internal/SimpleLockManager.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 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.
@@ -232,7 +232,7 @@ public class SimpleLockManager extends LockManager<SimpleLockManager.SimpleLock>
return false;
}
- AtomicBoolean result = new AtomicBoolean(false);
+ var result = new AtomicBoolean(false);
resource2lock.computeIfPresent(getResourceId(), (resourceId, curlock) -> {