X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=main%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpdpx%2Fmain%2Frest%2FXacmlPdpRestServer.java;h=67bbccaa4abe510c079a8e307da3b3959e323c68;hb=9bf471abe906598ffd2cd280d372e7cb9474a418;hp=f3b7a54e524c4afd325447fd1587ae238ea1e3f9;hpb=d2daf7ef5d003b5c5ae6a7083ccf676cc87a1d7b;p=policy%2Fxacml-pdp.git diff --git a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpRestServer.java b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpRestServer.java index f3b7a54e..67bbccaa 100644 --- a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpRestServer.java +++ b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpRestServer.java @@ -20,15 +20,14 @@ package org.onap.policy.pdpx.main.rest; +import java.nio.file.Paths; 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; @@ -46,16 +45,16 @@ public class XacmlPdpRestServer implements Startable { private List servers = new ArrayList<>(); private RestServerParameters restServerParameters; - - private ServiceLoader applicationLoader; + private String applicationPath; /** * Constructor for instantiating XacmlPdpRestServer. * * @param restServerParameters the rest server parameters */ - public XacmlPdpRestServer(final RestServerParameters restServerParameters) { + public XacmlPdpRestServer(final RestServerParameters restServerParameters, final String applicationPath) { this.restServerParameters = restServerParameters; + this.applicationPath = applicationPath; } /** @@ -65,9 +64,13 @@ public class XacmlPdpRestServer implements Startable { public boolean start() { try { // - // Look for existing policy types loaded into the system + // Initialize the applications - SEND PROPERTIES + // + XacmlPdpApplicationManager.initializeApplications(Paths.get(applicationPath)); + // + // Update statistics manager on the policy types // - locateExistingPolicyTypes(); + XacmlPdpStatisticsManager.setTotalPolicyTypesCount(XacmlPdpApplicationManager.getPolicyTypeCount()); // // Get the server properties // @@ -112,35 +115,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 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}. */