Xacml PDP Register/Unregister Changes
[policy/xacml-pdp.git] / main / src / main / java / org / onap / policy / pdpx / main / startstop / Main.java
index 65e0a31..b5915e1 100644 (file)
 
 package org.onap.policy.pdpx.main.startstop;
 
+import java.io.FileInputStream;
+import java.net.UnknownHostException;
 import java.util.Arrays;
+import java.util.Properties;
+import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClientException;
 import org.onap.policy.pdpx.main.PolicyXacmlPdpException;
+import org.onap.policy.pdpx.main.comm.XacmlPdpPapRegistration;
 import org.onap.policy.pdpx.main.parameters.XacmlPdpParameterGroup;
 import org.onap.policy.pdpx.main.parameters.XacmlPdpParameterHandler;
 import org.slf4j.Logger;
@@ -78,13 +83,25 @@ public class Main {
             return;
         }
 
+        // Read the properties
+        Properties props = new Properties();
+        try {
+            String propFile = arguments.getFullPropertyFilePath();
+            try (FileInputStream stream = new FileInputStream(propFile)) {
+                props.load(stream);
+            }
+        } catch (final Exception e) {
+            LOGGER.error("start of xacml pdp service failed", e);
+            return;
+        }
+
         // Now, create the activator for the policy xacml pdp service
-        activator = new XacmlPdpActivator(parameterGroup);
+        activator = new XacmlPdpActivator(parameterGroup, props);
 
         // Start the activator
         try {
-            activator.initialize();
-        } catch (final PolicyXacmlPdpException e) {
+            activator.start();
+        } catch (final RuntimeException e) {
             LOGGER.error("start of policy xacml pdp service failed, used parameters are " + Arrays.toString(args), e);
             return;
         }
@@ -117,13 +134,13 @@ public class Main {
      *
      * @throws PolicyXacmlPdpException on shutdown errors
      */
-    public void shutdown() throws PolicyXacmlPdpException {
+    public void shutdown() {
         // clear the parameterGroup variable
         parameterGroup = null;
 
         // clear the xacml pdp activator
         if (activator != null) {
-            activator.terminate();
+            activator.stop();
         }
     }
 
@@ -139,12 +156,8 @@ public class Main {
          */
         @Override
         public void run() {
-            try {
-                // Shutdown the policy xacml pdp service and wait for everything to stop
-                activator.terminate();
-            } catch (final PolicyXacmlPdpException e) {
-                LOGGER.warn("error occured during shut down of the policy xacml pdp service", e);
-            }
+            // Shutdown the policy xacml pdp service and wait for everything to stop
+            activator.stop();
         }
     }