aboutsummaryrefslogtreecommitdiffstats
path: root/policy-core/src/main/java/org
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2018-11-29 09:33:02 -0500
committerJim Hahn <jrh3@att.com>2018-11-29 09:35:21 -0500
commit2808374bda04dbe709253ca079dfb89d5dbea7dd (patch)
tree87eabdbd07e0d3f0cfcc1b81e230026aa713ba73 /policy-core/src/main/java/org
parentdbb701d2aae428e27c0590a42e2d371bb9bca59d (diff)
Remove Factory from various drools-pdp classes
Also merged changes from 'Rename test classes in drools-pdp'. Change-Id: I4d0a3a1b0b5523eadf38d1edb5aa86c404b69d19 Issue-ID: POLICY-1288 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'policy-core/src/main/java/org')
-rw-r--r--policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockManager.java49
1 files changed, 13 insertions, 36 deletions
diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockManager.java b/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockManager.java
index 33f4668c..487814cb 100644
--- a/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockManager.java
+++ b/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockManager.java
@@ -35,11 +35,6 @@ public class PolicyResourceLockManager extends SimpleLockManager {
private static Logger logger = LoggerFactory.getLogger(PolicyResourceLockManager.class);
/**
- * Used to access various objects.
- */
- private static Factory factory = new Factory();
-
- /**
* Used by junit tests.
*/
protected PolicyResourceLockManager() {
@@ -55,19 +50,6 @@ public class PolicyResourceLockManager extends SimpleLockManager {
return Singleton.instance;
}
- protected static Factory getFactory() {
- return factory;
- }
-
- /**
- * Sets the factory to be used by junit tests.
- *
- * @param factory the factory
- */
- protected static void setFactory(Factory factory) {
- PolicyResourceLockManager.factory = factory;
- }
-
@Override
public boolean lock(String resourceId, String owner, int holdSec) {
if (resourceId == null) {
@@ -205,9 +187,9 @@ public class PolicyResourceLockManager extends SimpleLockManager {
* @return first non-null value returned by an implementer, <i>continueValue</i> if
* they all returned <i>continueValue</i>
*/
- private static <T> T doIntercept(T continueValue, Function<PolicyResourceLockFeatureApi, T> func) {
+ private <T> T doIntercept(T continueValue, Function<PolicyResourceLockFeatureApi, T> func) {
- for (PolicyResourceLockFeatureApi impl : factory.getImplementers()) {
+ for (PolicyResourceLockFeatureApi impl : getImplementers()) {
try {
T result = func.apply(impl);
if (result != continueValue) {
@@ -222,6 +204,17 @@ public class PolicyResourceLockManager extends SimpleLockManager {
return continueValue;
}
+ // these may be overridden by junit tests
+
+ /**
+ * Get implementers.
+ *
+ * @return the list of feature implementers
+ */
+ protected List<PolicyResourceLockFeatureApi> getImplementers() {
+ return PolicyResourceLockFeatureApi.impl.getList();
+ }
+
/**
* Initialization-on-demand holder idiom.
*/
@@ -235,21 +228,5 @@ public class PolicyResourceLockManager extends SimpleLockManager {
private Singleton() {
super();
}
-
- }
-
- /**
- * Used to access various objects.
- */
- public static class Factory {
-
- /**
- * Get implementers.
- *
- * @return the list of feature implementers
- */
- public List<PolicyResourceLockFeatureApi> getImplementers() {
- return PolicyResourceLockFeatureApi.impl.getList();
- }
}
}