diff options
Diffstat (limited to 'policy-core/src/main/java/org')
6 files changed, 24 insertions, 16 deletions
diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java b/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java index 1eab676f..ec5ceb21 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java +++ b/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,12 +47,12 @@ import org.slf4j.LoggerFactory; */ public class PolicyContainer implements Startable { // get an instance of logger - private static Logger logger = LoggerFactory.getLogger(PolicyContainer.class); + private static final Logger logger = LoggerFactory.getLogger(PolicyContainer.class); // 'KieServices' singleton private static KieServices kieServices = KieServices.Factory.get(); // set of all 'PolicyContainer' instances - private static HashSet<PolicyContainer> containers = new HashSet<>(); + private static final HashSet<PolicyContainer> containers = new HashSet<>(); // maps feature objects to per-PolicyContainer data private ConcurrentHashMap<Object, Object> adjuncts = new ConcurrentHashMap<>(); @@ -65,7 +66,7 @@ public class PolicyContainer implements Startable { private volatile boolean isStarted = false; // maps session name into the associated 'PolicySession' instance - private HashMap<String, PolicySession> sessions = new HashMap<>(); + private final HashMap<String, PolicySession> sessions = new HashMap<>(); // if not null, this is a 'KieScanner' looking for updates private KieScanner scanner = null; @@ -171,7 +172,7 @@ public class PolicyContainer implements Startable { } } if (exception != null) { - // all of the 'newKieContainer' invocations failed -- throw the + // all the 'newKieContainer' invocations failed -- throw the // most recent exception throw exception; } @@ -263,7 +264,7 @@ public class PolicyContainer implements Startable { PolicySession session = null; KieSession kieSession = null; - // loop through all of the features, and give each one + // loop through all the features, and give each one // a chance to create the 'KieSession' for (PolicySessionFeatureApi feature : PolicySessionFeatureApiConstants.getImpl().getList()) { try { @@ -432,7 +433,7 @@ public class PolicyContainer implements Startable { /** * Get policy sessions. * - * @return all of the 'PolicySession' instances + * @return all the 'PolicySession' instances */ public Collection<PolicySession> getPolicySessions() { // KLUDGE WARNING: this is a temporary workaround -- if there are @@ -703,7 +704,7 @@ public class PolicyContainer implements Startable { var configDir = "config"; logger.info("PolicyContainer.main: configDir={}", configDir); - // invoke 'globalInit' on all of the features + // invoke 'globalInit' on all the features for (PolicySessionFeatureApi feature : PolicySessionFeatureApiConstants.getImpl().getList()) { try { feature.globalInit(args, configDir); diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java b/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java index 1f8a61c6..0c10e984 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java +++ b/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,14 +50,12 @@ import org.slf4j.LoggerFactory; * 2) Access to UEB * 3) Logging of events */ -public class PolicySession - implements AgendaEventListener, RuleRuntimeEventListener { +public class PolicySession implements AgendaEventListener, RuleRuntimeEventListener { // get an instance of logger - private static Logger logger = LoggerFactory.getLogger(PolicySession.class); + private static final Logger logger = LoggerFactory.getLogger(PolicySession.class); // supports 'getCurrentSession()' method - private static ThreadLocal<PolicySession> policySess = - new ThreadLocal<>(); + private static ThreadLocal<PolicySession> policySess = new ThreadLocal<>(); // name of the 'PolicySession' and associated 'KieSession' @Getter @@ -115,7 +114,7 @@ public class PolicySession return; } - // loop through all of the features, and give each one + // loop through all the features, and give each one // a chance to create the 'ThreadModel' for (PolicySessionFeatureApi feature : PolicySessionFeatureApiConstants.getImpl().getList()) { diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmx.java b/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmx.java index 0f4add77..4356d111 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmx.java +++ b/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmx.java @@ -3,6 +3,7 @@ * policy-core * ================================================================================ * Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +42,7 @@ public class PdpJmx implements PdpJmxMBean { return actions.longValue(); } - public void updateOccured() { + public void updateOccurred() { updates.incrementAndGet(); } diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysFailLock.java b/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysFailLock.java index dbb20883..df0ac151 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysFailLock.java +++ b/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysFailLock.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * 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,7 @@ package org.onap.policy.drools.core.lock; +import java.io.Serial; import lombok.NoArgsConstructor; /** @@ -27,6 +29,7 @@ import lombok.NoArgsConstructor; */ @NoArgsConstructor public class AlwaysFailLock extends LockImpl { + @Serial private static final long serialVersionUID = 1L; /** diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysSuccessLock.java b/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysSuccessLock.java index 6b1e1494..ced6c4c9 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysSuccessLock.java +++ b/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysSuccessLock.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +21,14 @@ package org.onap.policy.drools.core.lock; +import java.io.Serial; import lombok.NonNull; /** * Lock implementation whose operations always succeed. */ public class AlwaysSuccessLock extends LockImpl { + @Serial private static final long serialVersionUID = 1L; /** diff --git a/policy-core/src/main/java/org/onap/policy/drools/util/FeatureEnabledChecker.java b/policy-core/src/main/java/org/onap/policy/drools/util/FeatureEnabledChecker.java index 755e7a18..285a9a0a 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/util/FeatureEnabledChecker.java +++ b/policy-core/src/main/java/org/onap/policy/drools/util/FeatureEnabledChecker.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +26,7 @@ import lombok.AccessLevel; import lombok.NoArgsConstructor; /** - * Checks whether or not a feature is enabled. + * Checks whether a feature is enabled. */ @NoArgsConstructor(access = AccessLevel.PRIVATE) public class FeatureEnabledChecker { @@ -40,6 +41,6 @@ public class FeatureEnabledChecker { */ public static boolean isFeatureEnabled(Properties props, String propName) { String val = props.getProperty(propName); - return (val != null && Boolean.valueOf(val)); + return (Boolean.parseBoolean(val)); } } |