aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-02-25 11:36:23 -0500
committerJim Hahn <jrh3@att.com>2019-02-25 12:47:32 -0500
commit6329d5933f064f9418b300ef87235681fabd717d (patch)
tree1f8a914b40a385110dc4fd1998685156d375dee2 /main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
parent92eabbc64c1ea6f6bfe6df979ccc487e99e806be (diff)
Replace static methods with single getInstance
Some of the PAP classes use a number of static methods. These have been modified to use regular, non-static methods, a single static method, getInstance. Also modified PapStatisticsManager so its methods are thread safe. Changed "instance" to "current" for the activator, as it may be changed. Fix new checkstyle issues. Updated copyrights. Renamed test class to be consistent. Added test for getCurrent/setCurrent and isAlive. Change-Id: Id6df55fa4c116852032ad61f80f899fcd292f864 Issue-ID: POLICY-1444 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java')
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java38
1 files changed, 17 insertions, 21 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java b/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
index 9fb3535b..18b87641 100644
--- a/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
+++ b/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
@@ -21,6 +21,8 @@
package org.onap.policy.pap.main.startstop;
+import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.pap.main.PolicyPapException;
import org.onap.policy.pap.main.parameters.PapParameterGroup;
@@ -39,7 +41,19 @@ public class PapActivator {
private static final Logger LOGGER = LoggerFactory.getLogger(PapActivator.class);
private final PapParameterGroup papParameterGroup;
- private static volatile boolean alive = false;
+
+ /**
+ * The current activator. This is initialized to a dummy instance used until the real
+ * one has been configured.
+ */
+ @Getter
+ @Setter
+ private static volatile PapActivator current = new PapActivator(null);
+
+ @Getter
+ @Setter(lombok.AccessLevel.PRIVATE)
+ private volatile boolean alive = false;
+
private PapRestServer restServer;
/**
@@ -61,7 +75,7 @@ public class PapActivator {
LOGGER.debug("Policy pap starting as a service . . .");
startPapRestServer();
registerToParameterService(papParameterGroup);
- PapActivator.setAlive(true);
+ setAlive(true);
LOGGER.debug("Policy pap started as a service");
} catch (final Exception exp) {
LOGGER.error("Policy pap service startup failed", exp);
@@ -77,7 +91,7 @@ public class PapActivator {
public void terminate() throws PolicyPapException {
try {
deregisterToParameterService(papParameterGroup);
- PapActivator.setAlive(false);
+ setAlive(false);
// Stop the pap rest server
restServer.stop();
@@ -115,24 +129,6 @@ public class PapActivator {
}
/**
- * Returns the alive status of pap service.
- *
- * @return the alive
- */
- public static boolean isAlive() {
- return alive;
- }
-
- /**
- * Change the alive status of pap service.
- *
- * @param status the status
- */
- private static void setAlive(final boolean status) {
- alive = status;
- }
-
- /**
* Starts the pap rest server using configuration parameters.
*
* @throws PolicyPapException if server start fails