summaryrefslogtreecommitdiffstats
path: root/policy-management/src/main/java/org
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2023-10-04 16:13:59 +0100
committeradheli.tavares <adheli.tavares@est.tech>2023-10-04 16:14:33 +0100
commitb6d09ef9da41191199f2da7958d5b418ed2da8d9 (patch)
tree0a14755192f1418ab4c14e06858d0993a090bb40 /policy-management/src/main/java/org
parent396f60280265a37379916ad12752a94691118f65 (diff)
Remove AAF from drools-pdp
Issue-ID: POLICY-4592 Change-Id: Ibe7fb63017f862bdab4a80444a00324040b1ab87 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'policy-management/src/main/java/org')
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/controller/DroolsController.java4
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java6
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java28
3 files changed, 14 insertions, 24 deletions
diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsController.java b/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsController.java
index 5b4e4ded..27a3289a 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsController.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsController.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -131,7 +132,7 @@ public interface DroolsController extends Startable, Lockable {
PolicyContainer getContainer();
/**
- * Does it owns the coder.
+ * Does it own the coder.
*
* @param coderClass the encoder object
* @param modelHash the hash for the model
@@ -161,7 +162,6 @@ public interface DroolsController extends Startable, Lockable {
* @param decoderConfigurations - decoder configurations
* @param encoderConfigurations - encoder configurations
*
- * @throws Exception from within drools libraries
* @throws LinkageError from within drools libraries
*/
void updateToVersion(String newGroupId, String newArtifactId, String newVersion,
diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java b/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java
index 3a50b9f7..5491eac7 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -59,11 +60,6 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
protected Map<String, DroolsController> droolsControllers = new HashMap<>();
/**
- * Null Drools Controller.
- */
- protected NullDroolsController nullDroolsController = new NullDroolsController();
-
- /**
* Constructs the object.
*/
public IndexedDroolsControllerFactory() {
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 d7d387b8..e93adec5 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
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
+import lombok.Getter;
import lombok.NonNull;
import org.apache.commons.collections4.queue.CircularFifoQueue;
import org.drools.core.ClassObjectFilter;
@@ -117,7 +119,10 @@ public class MavenDroolsController implements DroolsController {
/**
* original Drools Model/Rules classloader hash.
+ * -- GETTER --
+ * Get model class loader hash.
*/
+ @Getter
protected int modelClassLoaderHash;
/**
@@ -272,7 +277,7 @@ public class MavenDroolsController implements DroolsController {
String potentialCodedClass = coderFilter.getCodedClass();
JsonProtocolFilter protocolFilter = coderFilter.getFilter();
- if (!isClass(potentialCodedClass)) {
+ if (isNotAClass(potentialCodedClass)) {
throw makeRetrieveEx(potentialCodedClass);
} else {
logClassFetched(potentialCodedClass);
@@ -306,7 +311,7 @@ public class MavenDroolsController implements DroolsController {
&& !customGsonCoder.getClassContainer().isEmpty()) {
String customGsonCoderClass = customGsonCoder.getClassContainer();
- if (!isClass(customGsonCoderClass)) {
+ if (isNotAClass(customGsonCoderClass)) {
throw makeRetrieveEx(customGsonCoderClass);
} else {
logClassFetched(customGsonCoderClass);
@@ -371,7 +376,7 @@ public class MavenDroolsController implements DroolsController {
@Override
public boolean ownsCoder(Class<?> coderClass, int modelHash) {
- if (!isClass(coderClass.getName())) {
+ if (isNotAClass(coderClass.getName())) {
logger.error("{}{} cannot be retrieved. ", this, coderClass.getName());
return false;
}
@@ -624,15 +629,6 @@ public class MavenDroolsController implements DroolsController {
return this.policyContainer.getGroupId();
}
- /**
- * Get model class loader hash.
- *
- * @return the modelClassLoaderHash
- */
- public int getModelClassLoaderHash() {
- return modelClassLoaderHash;
- }
-
@Override
public synchronized boolean lock() {
logger.info("LOCK: {}", this);
@@ -706,9 +702,7 @@ public class MavenDroolsController implements DroolsController {
* @return the attached Policy Container
*/
protected List<PolicySession> getSessions() {
- List<PolicySession> sessions = new ArrayList<>();
- sessions.addAll(this.policyContainer.getPolicySessions());
- return sessions;
+ return new ArrayList<>(this.policyContainer.getPolicySessions());
}
/**
@@ -1007,7 +1001,7 @@ public class MavenDroolsController implements DroolsController {
return new PolicyContainer(groupId, artifactId, version);
}
- protected boolean isClass(String className) {
- return ReflectionUtil.isClass(this.policyContainer.getClassLoader(), className);
+ protected boolean isNotAClass(String className) {
+ return !ReflectionUtil.isClass(this.policyContainer.getClassLoader(), className);
}
}