Change getCanonicalName() to getName() in xacml-pdp
[policy/xacml-pdp.git] / main / src / main / java / org / onap / policy / pdpx / main / rest / XacmlPdpRestServer.java
index f3b7a54..4b89cb1 100644 (file)
 package org.onap.policy.pdpx.main.rest;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
-import java.util.ServiceLoader;
-
 import org.onap.policy.common.capabilities.Startable;
 import org.onap.policy.common.endpoints.http.server.HttpServletServer;
-import org.onap.policy.pdp.xacml.application.common.XacmlApplicationServiceProvider;
+import org.onap.policy.common.gson.GsonMessageBodyHandler;
 import org.onap.policy.pdpx.main.parameters.RestServerParameters;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -45,9 +42,7 @@ public class XacmlPdpRestServer implements Startable {
 
     private List<HttpServletServer> servers = new ArrayList<>();
 
-    private RestServerParameters restServerParameters;
-
-    private ServiceLoader<XacmlApplicationServiceProvider> applicationLoader;
+    private final RestServerParameters restServerParameters;
 
     /**
      * Constructor for instantiating XacmlPdpRestServer.
@@ -64,10 +59,8 @@ public class XacmlPdpRestServer implements Startable {
     @Override
     public boolean start() {
         try {
-            //
-            // Look for existing policy types loaded into the system
-            //
-            locateExistingPolicyTypes();
+            LOGGER.info("Starting XacmlPdpRestServer...");
+
             //
             // Get the server properties
             //
@@ -77,10 +70,11 @@ public class XacmlPdpRestServer implements Startable {
             //
             for (final HttpServletServer server : servers) {
                 if (server.isAaf()) {
-                    server.addFilterClass(null, XacmlPdpAafFilter.class.getCanonicalName());
+                    server.addFilterClass(null, XacmlPdpAafFilter.class.getName());
                 }
                 server.start();
             }
+            LOGGER.info("servers are started");
         } catch (final Exception exp) {
             LOGGER.error("Failed to start xacml pdp http server", exp);
             return false;
@@ -101,7 +95,7 @@ public class XacmlPdpRestServer implements Startable {
         props.setProperty(HTTP_SERVER_SERVICES + SEPARATOR + restServerParameters.getName() + ".port",
                 Integer.toString(restServerParameters.getPort()));
         props.setProperty(HTTP_SERVER_SERVICES + SEPARATOR + restServerParameters.getName() + ".restClasses",
-                XacmlPdpRestController.class.getCanonicalName());
+                XacmlPdpRestController.class.getName());
         props.setProperty(HTTP_SERVER_SERVICES + SEPARATOR + restServerParameters.getName() + ".managed", "false");
         props.setProperty(HTTP_SERVER_SERVICES + SEPARATOR + restServerParameters.getName() + ".swagger", "true");
         props.setProperty(HTTP_SERVER_SERVICES + SEPARATOR + restServerParameters.getName() + ".userName",
@@ -112,35 +106,11 @@ public class XacmlPdpRestServer implements Startable {
                 String.valueOf(restServerParameters.isHttps()));
         props.setProperty(HTTP_SERVER_SERVICES + SEPARATOR + restServerParameters.getName() + ".aaf",
                 String.valueOf(restServerParameters.isAaf()));
+        props.setProperty(HTTP_SERVER_SERVICES + SEPARATOR + restServerParameters.getName() + ".serialization.provider",
+                GsonMessageBodyHandler.class.getName());
         return props;
     }
 
-    private void locateExistingPolicyTypes() {
-        //
-        // Load service
-        //
-        applicationLoader = ServiceLoader.load(XacmlApplicationServiceProvider.class);
-        //
-        // Iterate through them
-        //
-        StringBuilder strDump = new StringBuilder("Loaded applications:" + System.lineSeparator());
-        Iterator<XacmlApplicationServiceProvider> iterator = applicationLoader.iterator();
-        long types = 0;
-        while (iterator.hasNext()) {
-            XacmlApplicationServiceProvider application = iterator.next();
-            strDump.append(application.applicationName());
-            strDump.append(" supports ");
-            strDump.append(application.supportedPolicyTypes());
-            types += application.supportedPolicyTypes().size();
-            strDump.append(System.lineSeparator());
-        }
-        LOGGER.debug("{}", strDump);
-        //
-        // Update statistics manager
-        //
-        XacmlPdpStatisticsManager.setTotalPolicyTypesCount(types);
-    }
-
     /**
      * {@inheritDoc}.
      */