Changes for packaging services-onappf and some refactoring 54/85054/2
authora.sreekumar <ajith.sreekumar@est.tech>
Thu, 11 Apr 2019 16:56:29 +0000 (16:56 +0000)
committera.sreekumar <ajith.sreekumar@est.tech>
Thu, 11 Apr 2019 16:56:29 +0000 (16:56 +0000)
1) Added the code for packaging PDP-A.
2) Updating the package names.
3) Updating the dependencies in services-onappf. Some dependencies can
be removed as they are brought in while packaging.
4) Some other minor changes.

Change-Id: Idf62d7854f3435806a9e8aa975138fbfd45e3ea8
Issue-ID: POLICY-1632
Signed-off-by: a.sreekumar <ajith.sreekumar@est.tech>
37 files changed:
packages/apex-pdp-package-full/pom.xml
packages/apex-pdp-package-full/src/main/package/scripts/apexApps.bat
packages/apex-pdp-package-full/src/main/package/scripts/apexApps.sh
packages/apex-pdp-package-full/src/main/package/scripts/apexOnapPf.bat [new file with mode: 0644]
packages/apex-pdp-package-full/src/main/package/scripts/apexOnapPf.sh [new file with mode: 0644]
services/services-onappf/pom.xml
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java [moved from services/services-onappf/src/main/java/org/onap/policy/apex/starter/ApexStarterActivator.java with 90% similarity]
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterCommandLineArguments.java [moved from services/services-onappf/src/main/java/org/onap/policy/apex/starter/ApexStarterCommandLineArguments.java with 97% similarity]
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterConstants.java [moved from services/services-onappf/src/main/java/org/onap/policy/apex/starter/ApexStarterConstants.java with 97% similarity]
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java [moved from services/services-onappf/src/main/java/org/onap/policy/apex/starter/ApexStarterMain.java with 94% similarity]
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/comm/PdpStateChangeListener.java [moved from services/services-onappf/src/main/java/org/onap/policy/apex/starter/comm/PdpStateChangeListener.java with 93% similarity]
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/comm/PdpStatusPublisher.java [moved from services/services-onappf/src/main/java/org/onap/policy/apex/starter/comm/PdpStatusPublisher.java with 95% similarity]
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/comm/PdpUpdateListener.java [moved from services/services-onappf/src/main/java/org/onap/policy/apex/starter/comm/PdpUpdateListener.java with 93% similarity]
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/exception/ApexStarterException.java [moved from services/services-onappf/src/main/java/org/onap/policy/apex/starter/exception/ApexStarterException.java with 97% similarity]
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/exception/ApexStarterRunTimeException.java [moved from services/services-onappf/src/main/java/org/onap/policy/apex/starter/exception/ApexStarterRunTimeException.java with 97% similarity]
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java [moved from services/services-onappf/src/main/java/org/onap/policy/apex/starter/engine/ApexEngineHandler.java with 94% similarity]
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java [moved from services/services-onappf/src/main/java/org/onap/policy/apex/starter/handler/PdpMessageHandler.java with 95% similarity]
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java [moved from services/services-onappf/src/main/java/org/onap/policy/apex/starter/handler/PdpStateChangeMessageHandler.java with 95% similarity]
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java [moved from services/services-onappf/src/main/java/org/onap/policy/apex/starter/handler/PdpUpdateMessageHandler.java with 96% similarity]
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterGroup.java [moved from services/services-onappf/src/main/java/org/onap/policy/apex/starter/parameters/ApexStarterParameterGroup.java with 96% similarity]
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java [moved from services/services-onappf/src/main/java/org/onap/policy/apex/starter/parameters/ApexStarterParameterHandler.java with 94% similarity]
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/PdpStatusParameters.java [moved from services/services-onappf/src/main/java/org/onap/policy/apex/starter/parameters/PdpStatusParameters.java with 96% similarity]
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ToscaPolicyTypeIdentifierParameters.java [moved from services/services-onappf/src/main/java/org/onap/policy/apex/starter/parameters/ToscaPolicyTypeIdentifierParameters.java with 96% similarity]
services/services-onappf/src/main/resources/config/OnapPfConfig.json [new file with mode: 0644]
services/services-onappf/src/main/resources/config/topic.properties [new file with mode: 0644]
services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterActivator.java [moved from services/services-onappf/src/test/java/org/onap/policy/apex/starter/TestApexStarterActivator.java with 87% similarity]
services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterConstants.java [moved from services/services-onappf/src/test/java/org/onap/policy/apex/starter/TestApexStarterConstants.java with 92% similarity]
services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterMain.java [moved from services/services-onappf/src/test/java/org/onap/policy/apex/starter/TestApexStarterMain.java with 90% similarity]
services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java [moved from services/services-onappf/src/test/java/org/onap/policy/apex/starter/comm/TestPdpStateChangeListener.java with 91% similarity]
services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java [moved from services/services-onappf/src/test/java/org/onap/policy/apex/starter/comm/TestPdpUpdateListener.java with 89% similarity]
services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/exception/TestExceptions.java [moved from services/services-onappf/src/test/java/org/onap/policy/apex/starter/exception/TestExceptions.java with 86% similarity]
services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/CommonTestData.java [moved from services/services-onappf/src/test/java/org/onap/policy/apex/starter/parameters/CommonTestData.java with 96% similarity]
services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterGroup.java [moved from services/services-onappf/src/test/java/org/onap/policy/apex/starter/parameters/TestApexStarterParameterGroup.java with 96% similarity]
services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterHandler.java [moved from services/services-onappf/src/test/java/org/onap/policy/apex/starter/parameters/TestApexStarterParameterHandler.java with 94% similarity]
services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestPdpStatusParameters.java [moved from services/services-onappf/src/test/java/org/onap/policy/apex/starter/parameters/TestPdpStatusParameters.java with 94% similarity]
services/services-onappf/src/test/resources/ApexStarterConfigParameters.json
services/services-onappf/src/test/resources/topic.properties

index de2ccf7..078088b 100644 (file)
             <artifactId>services-engine</artifactId>
             <version>${project.version}</version>
         </dependency>
-
+        <dependency>
+            <groupId>org.onap.policy.apex-pdp.services</groupId>
+            <artifactId>services-onappf</artifactId>
+            <version>${project.version}</version>
+        </dependency>
         <!-- Client Servlet applications -->
         <dependency>
             <groupId>org.onap.policy.apex-pdp.client</groupId>
                         </goals>
                         <configuration>
                             <artifactItems>
+                                <artifactItem>
+                                    <groupId>org.onap.policy.apex-pdp.services</groupId>
+                                    <artifactId>services-onappf</artifactId>
+                                    <version>${project.version}</version>
+                                    <type>jar</type>
+                                    <overWrite>false</overWrite>
+                                    <outputDirectory>${project.build.directory}/etc/onappf</outputDirectory>
+                                    <includes>config/*</includes>
+                                </artifactItem>
                                 <artifactItem>
                                     <groupId>org.onap.policy.apex-pdp.auth</groupId>
                                     <artifactId>cli-editor</artifactId>
index 848498b..9798fa5 100644 (file)
@@ -82,6 +82,7 @@ set APEX_APP_MAP[eng-deployment]=java -Dlogback.configurationFile=%APEX_HOME%\et
 set APEX_APP_MAP[eng-monitoring]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -jar %APEX_HOME%\lib\applications\client-monitoring-%_VERSION%-monitoring.jar
 set APEX_APP_MAP[full-client]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -jar %APEX_HOME%\lib\applications\client-full-%_VERSION%-full.jar
 set APEX_APP_MAP[event-generator]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -cp %CLASSPATH% %_CONFIG% org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.EventGenerator
+set APEX_APP_MAP[onappf]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -cp %CLASSPATH% %_CONFIG% org.onap.policy.apex.services.onappf.ApexStarterMain
 
 :: array of applications with name=description
 :: declare -A APEX_APP_DESCR_MAP
@@ -96,6 +97,7 @@ set APEX_APP_DESCR_MAP[eng-deployment]=starts the APEX deployment client in a si
 set APEX_APP_DESCR_MAP[eng-monitoring]=starts the APEX engine monitoring client in a simple webserver
 set APEX_APP_DESCR_MAP[full-client]=starts the full APEX client (rest editor, deployment, monitoring) in a simple webserver
 set APEX_APP_DESCR_MAP["event-generator"]=starts the event generator in a simple webserver for performance testing
+set APEX_APP_DESCR_MAP[onappf]=starts the ApexStarter which handles the Apex Engine based on instructions from PAP
 
 :: no command line means help, -h means help
 if "%1" == "" goto Help
index c5569ba..52e1f3d 100755 (executable)
@@ -91,6 +91,7 @@ APEX_APP_MAP["eng-deployment"]="java -Dlogback.configurationFile=$APEX_HOME/etc/
 APEX_APP_MAP["eng-monitoring"]="java -Dlogback.configurationFile=$APEX_HOME/etc/logback.xml -jar $APEX_HOME/lib/applications/client-monitoring-$_version-monitoring.jar"
 APEX_APP_MAP["full-client"]="java -Dlogback.configurationFile=$APEX_HOME/etc/logback.xml -jar $APEX_HOME/lib/applications/client-full-$_version-full.jar"
 APEX_APP_MAP["event-gen"]="java -Dlogback.configurationFile=$APEX_HOME/etc/logback.xml -cp ${CLASSPATH} $_config org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.EventGenerator"
+APEX_APP_MAP["onappf"]="java -Dlogback.configurationFile=$APEX_HOME/etc/logback.xml -cp ${CLASSPATH} $_config org.onap.policy.apex.services.onappf.ApexStarterMain"
 
 ## array of applications with name=description
 declare -A APEX_APP_DESCR_MAP
@@ -105,6 +106,7 @@ APEX_APP_DESCR_MAP["eng-deployment"]="starts the APEX deployment client in a sim
 APEX_APP_DESCR_MAP["eng-monitoring"]="starts the APEX engine monitoring client in a simple webserver"
 APEX_APP_DESCR_MAP["full-client"]="starts the full APEX client (rest editor, deployment, monitoring) in a simple webserver"
 APEX_APP_DESCR_MAP["event-generator"]="starts the event generator in a simple webserver for performance testing"
+APEX_APP_DESCR_MAP["onappf"]="starts the ApexStarter which handles the Apex Engine based on instructions from PAP"
 
 ##
 ## Help screen and exit condition (i.e. too few arguments)
diff --git a/packages/apex-pdp-package-full/src/main/package/scripts/apexOnapPf.bat b/packages/apex-pdp-package-full/src/main/package/scripts/apexOnapPf.bat
new file mode 100644 (file)
index 0000000..4553123
--- /dev/null
@@ -0,0 +1,52 @@
+:: ============LICENSE_START=======================================================
+::  Copyright (C) 2019 Nordix Foundation.
+:: ================================================================================
+:: Licensed under the Apache License, Version 2.0 (the "License");
+:: you may not use this file except in compliance with the License.
+:: You may obtain a copy of the License at
+::
+::      http://www.apache.org/licenses/LICENSE-2.0
+::
+:: Unless required by applicable law or agreed to in writing, software
+:: distributed under the License is distributed on an "AS IS" BASIS,
+:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+:: See the License for the specific language governing permissions and
+:: limitations under the License.
+::
+:: SPDX-License-Identifier: Apache-2.0
+:: ============LICENSE_END=========================================================
+
+::
+:: Script to run the onappf PDP-A, calls apexApps.bat
+::
+:: @package    org.onap.policy.apex
+:: @author     Ajith Sreekumar <ajith.sreekumar@est.tech>
+:: @version    v1.0.0
+
+::
+:: DO NOT CHANGE CODE BELOW, unless you know what you are doing
+::
+
+@echo off
+setlocal enableDelayedExpansion
+
+
+if defined APEX_HOME (
+   if exist "%APEX_HOME%\" (
+      set _dummy=dir
+   ) else (
+      echo[
+      echo Apex directory 'APEX_HOME' not a directory
+      echo Please set environment for 'APEX_HOME'
+      echo[
+      exit /b
+   )
+) else (
+    echo[
+    echo Apex directory 'APEX_HOME' not set
+    echo Please set environment for 'APEX_HOME'
+    echo[
+    exit /b
+)
+
+%APEX_HOME%\bin\apexApps.bat onappf %*
diff --git a/packages/apex-pdp-package-full/src/main/package/scripts/apexOnapPf.sh b/packages/apex-pdp-package-full/src/main/package/scripts/apexOnapPf.sh
new file mode 100644 (file)
index 0000000..3eaa259
--- /dev/null
@@ -0,0 +1,67 @@
+#!/bin/bash
+#
+# ============LICENSE_START=======================================================
+#  Copyright (C) 2019 Nordix Foundation.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+#
+
+
+##
+## Script to run onappf PDP-A, calls apexApps.sh
+##
+## @package    org.onap.policy.apex
+## @author     Ajith Sreekumar <ajith.sreekumar@est.tech>
+## @version    v1.0.0
+
+
+if [ -z $APEX_USER ]
+then
+   APEX_USER="apexuser"
+fi
+
+id $APEX_USER > /dev/null 2>& 1
+if [ "$?" -ne "0" ]
+then
+   echo 'cannot run apex, user "'$APEX_USER'" does not exit'
+   exit
+fi
+
+if [ $(whoami) != "$APEX_USER" ]
+then
+   echo 'Apex must be run as user "'$APEX_USER'"'
+   exit
+fi
+
+if [ -z $APEX_HOME ]
+then
+   APEX_HOME="/opt/app/policy/apex-pdp"
+fi
+
+if [ ! -d $APEX_HOME ]
+then
+   echo
+   echo 'Apex directory "'$APEX_HOME'" not set or not a directory'
+   echo "Please set environment for 'APEX_HOME'"
+   exit
+fi
+
+if [ $(whoami) == "$APEX_USER" ]
+then
+   $APEX_HOME/bin/apexApps.sh onappf $*
+else
+   su $APEX_USER -c "$APEX_HOME/bin/apexApps.sh onappf $*"
+fi
index ef23ae7..81df894 100644 (file)
     <description>This module handles the registration/deregistration of apex-pdp to ONAP Policy Framework.</description>
 
     <dependencies>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.onap.policy.apex-pdp.services</groupId>
             <artifactId>services-engine</artifactId>
             <version>${project.version}</version>
         </dependency>
-        <!-- Plugins for Context Distribution -->
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-distribution</groupId>
-            <artifactId>plugins-context-distribution-hazelcast</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-distribution</groupId>
-            <artifactId>plugins-context-distribution-infinispan</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
-        <!-- Plugins for Context Locking -->
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-locking</groupId>
-            <artifactId>plugins-context-locking-hazelcast</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-locking</groupId>
-            <artifactId>plugins-context-locking-curator</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
-        <!-- Plugins for Context Schemas -->
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-schema</groupId>
-            <artifactId>plugins-context-schema-avro</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
-        <!-- Plugins for Executors -->
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
-            <artifactId>plugins-executor-java</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
-            <artifactId>plugins-executor-javascript</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
-            <artifactId>plugins-executor-jruby</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
-            <artifactId>plugins-executor-jython</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
-            <artifactId>plugins-executor-mvel</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
-        <!-- Plugins for Persistence of Models over JPA -->
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-persistence.plugins-persistence-jpa</groupId>
-            <artifactId>plugins-persistence-jpa-eclipselink</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-persistence.plugins-persistence-jpa</groupId>
-            <artifactId>plugins-persistence-jpa-hibernate</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
-        <!-- Plugins for event carrier technologies -->
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-carrier</groupId>
-            <artifactId>plugins-event-carrier-kafka</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-carrier</groupId>
-            <artifactId>plugins-event-carrier-websocket</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-carrier</groupId>
-            <artifactId>plugins-event-carrier-jms</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-carrier</groupId>
-            <artifactId>plugins-event-carrier-restclient</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-carrier</groupId>
-            <artifactId>plugins-event-carrier-restserver</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-carrier</groupId>
-            <artifactId>plugins-event-carrier-restrequestor</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        
-        <!-- Plugins for event protocols -->
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-protocol</groupId>
-            <artifactId>plugins-event-protocol-xml</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-protocol</groupId>
-            <artifactId>plugins-event-protocol-jms</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
-
         <dependency>
             <groupId>org.onap.policy.common</groupId>
             <artifactId>policy-endpoints</artifactId>
                     <groupId>javax.ws.rs</groupId>
                     <artifactId>javax.ws.rs-api</artifactId>
                 </exclusion>
+                <exclusion>
+                    <groupId>org.glassfish.hk2</groupId>
+                    <artifactId>hk2-api</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.glassfish.hk2.external</groupId>
+                    <artifactId>javax.inject</artifactId>
+                </exclusion>
             </exclusions>
             <version>${version.policy.common}</version>
         </dependency>
-
         <dependency>
             <groupId>org.glassfish.jersey.inject</groupId>
             <artifactId>jersey-hk2</artifactId>
             <version>${version.jersey}</version>
         </dependency>
-
         <dependency>
             <groupId>org.onap.policy.common</groupId>
             <artifactId>utils-test</artifactId>
             </exclusions>
             <version>${version.policy.models}</version>
         </dependency>
+
+        <!--test dependencies -->
         <dependency>
             <groupId>org.assertj</groupId>
             <artifactId>assertj-core</artifactId>
             <artifactId>powermock-api-mockito</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter;
+package org.onap.policy.apex.services.onappf;
 
 import java.util.List;
 import java.util.Properties;
@@ -26,13 +26,13 @@ import java.util.Properties;
 import lombok.Getter;
 import lombok.Setter;
 
-import org.onap.policy.apex.starter.comm.PdpStateChangeListener;
-import org.onap.policy.apex.starter.comm.PdpStatusPublisher;
-import org.onap.policy.apex.starter.comm.PdpUpdateListener;
-import org.onap.policy.apex.starter.exception.ApexStarterException;
-import org.onap.policy.apex.starter.exception.ApexStarterRunTimeException;
-import org.onap.policy.apex.starter.handler.PdpMessageHandler;
-import org.onap.policy.apex.starter.parameters.ApexStarterParameterGroup;
+import org.onap.policy.apex.services.onappf.comm.PdpStateChangeListener;
+import org.onap.policy.apex.services.onappf.comm.PdpStatusPublisher;
+import org.onap.policy.apex.services.onappf.comm.PdpUpdateListener;
+import org.onap.policy.apex.services.onappf.exception.ApexStarterException;
+import org.onap.policy.apex.services.onappf.exception.ApexStarterRunTimeException;
+import org.onap.policy.apex.services.onappf.handler.PdpMessageHandler;
+import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterGroup;
 import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
 import org.onap.policy.common.endpoints.event.comm.TopicSink;
 import org.onap.policy.common.endpoints.event.comm.TopicSource;
@@ -128,8 +128,6 @@ public class ApexStarterActivator {
     private void stopAndRemovePdpStatusPublisher() {
         final PdpStatusPublisher pdpStatusPublisher =
                 Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
-        // send a final heartbeat with terminated status
-        pdpStatusPublisher.send(new PdpMessageHandler().getTerminatedPdpStatus());
         pdpStatusPublisher.terminate();
         Registry.unregister(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER);
     }
@@ -164,6 +162,10 @@ public class ApexStarterActivator {
             throw new IllegalStateException("activator is not running");
         }
         try {
+            final PdpStatusPublisher pdpStatusPublisher =
+                    Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
+            // send a final heartbeat with terminated status
+            pdpStatusPublisher.send(new PdpMessageHandler().getTerminatedPdpStatus());
             manager.stop();
             Registry.unregister(ApexStarterConstants.REG_APEX_STARTER_ACTIVATOR);
         } catch (final ServiceManagerException exp) {
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter;
+package org.onap.policy.apex.services.onappf;
 
 import java.io.File;
 import java.io.PrintWriter;
@@ -33,8 +33,8 @@ import org.apache.commons.cli.Option;
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
 import org.apache.log4j.chainsaw.Main;
-import org.onap.policy.apex.starter.exception.ApexStarterException;
-import org.onap.policy.apex.starter.exception.ApexStarterRunTimeException;
+import org.onap.policy.apex.services.onappf.exception.ApexStarterException;
+import org.onap.policy.apex.services.onappf.exception.ApexStarterRunTimeException;
 import org.onap.policy.common.utils.resources.ResourceUtils;
 
 /**
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter;
+package org.onap.policy.apex.services.onappf;
 
 import java.io.FileInputStream;
 import java.util.Arrays;
 import java.util.Properties;
 
-import org.onap.policy.apex.starter.exception.ApexStarterException;
-import org.onap.policy.apex.starter.parameters.ApexStarterParameterGroup;
-import org.onap.policy.apex.starter.parameters.ApexStarterParameterHandler;
+import org.onap.policy.apex.services.onappf.exception.ApexStarterException;
+import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterGroup;
+import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterHandler;
 import org.onap.policy.common.utils.services.Registry;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -18,9 +18,9 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter.comm;
+package org.onap.policy.apex.services.onappf.comm;
 
-import org.onap.policy.apex.starter.handler.PdpStateChangeMessageHandler;
+import org.onap.policy.apex.services.onappf.handler.PdpStateChangeMessageHandler;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.listeners.ScoListener;
 import org.onap.policy.common.utils.coder.StandardCoderObject;
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter.comm;
+package org.onap.policy.apex.services.onappf.comm;
 
 import java.util.List;
 import java.util.Timer;
 import java.util.TimerTask;
 
-import org.onap.policy.apex.starter.handler.PdpMessageHandler;
+import org.onap.policy.apex.services.onappf.handler.PdpMessageHandler;
 import org.onap.policy.common.endpoints.event.comm.TopicSink;
 import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
 import org.onap.policy.models.pdp.concepts.PdpStatus;
@@ -18,9 +18,9 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter.comm;
+package org.onap.policy.apex.services.onappf.comm;
 
-import org.onap.policy.apex.starter.handler.PdpUpdateMessageHandler;
+import org.onap.policy.apex.services.onappf.handler.PdpUpdateMessageHandler;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.listeners.ScoListener;
 import org.onap.policy.common.utils.coder.StandardCoderObject;
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter.engine;
+package org.onap.policy.apex.services.onappf.handler;
 
 import com.google.gson.JsonObject;
 
@@ -30,7 +30,7 @@ import java.nio.file.Path;
 
 import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
 import org.onap.policy.apex.service.engine.main.ApexMain;
-import org.onap.policy.apex.starter.exception.ApexStarterException;
+import org.onap.policy.apex.services.onappf.exception.ApexStarterException;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
 import org.slf4j.Logger;
@@ -70,7 +70,7 @@ public class ApexEngineHandler {
         final String modelFilePath = createFile(policyModel, "modelFile");
 
         final String apexConfigFilePath = createFile(apexConfig, "apexConfigFile");
-        final String[] apexArgs = { "-rfr", "target/classes", "-c", apexConfigFilePath, "-m", modelFilePath };
+        final String[] apexArgs = { "-c", apexConfigFilePath, "-m", modelFilePath };
         LOGGER.debug("Starting apex engine.");
         apexMain = new ApexMain(apexArgs);
     }
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter.handler;
+package org.onap.policy.apex.services.onappf.handler;
 
 import java.util.ArrayList;
 import java.util.List;
 
-import org.onap.policy.apex.starter.ApexStarterConstants;
-import org.onap.policy.apex.starter.parameters.PdpStatusParameters;
-import org.onap.policy.apex.starter.parameters.ToscaPolicyTypeIdentifierParameters;
+import org.onap.policy.apex.services.onappf.ApexStarterConstants;
+import org.onap.policy.apex.services.onappf.parameters.PdpStatusParameters;
+import org.onap.policy.apex.services.onappf.parameters.ToscaPolicyTypeIdentifierParameters;
 import org.onap.policy.common.utils.services.Registry;
 import org.onap.policy.models.pdp.concepts.PdpResponseDetails;
 import org.onap.policy.models.pdp.concepts.PdpStatus;
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter.handler;
+package org.onap.policy.apex.services.onappf.handler;
 
 import java.util.List;
 
-import org.onap.policy.apex.starter.ApexStarterConstants;
-import org.onap.policy.apex.starter.comm.PdpStatusPublisher;
-import org.onap.policy.apex.starter.engine.ApexEngineHandler;
-import org.onap.policy.apex.starter.exception.ApexStarterException;
+import org.onap.policy.apex.services.onappf.ApexStarterConstants;
+import org.onap.policy.apex.services.onappf.comm.PdpStatusPublisher;
+import org.onap.policy.apex.services.onappf.exception.ApexStarterException;
 import org.onap.policy.common.utils.services.Registry;
 import org.onap.policy.models.pdp.concepts.PdpResponseDetails;
 import org.onap.policy.models.pdp.concepts.PdpStateChange;
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter.handler;
+package org.onap.policy.apex.services.onappf.handler;
 
 import java.util.List;
 
-import org.onap.policy.apex.starter.ApexStarterConstants;
-import org.onap.policy.apex.starter.comm.PdpStatusPublisher;
-import org.onap.policy.apex.starter.engine.ApexEngineHandler;
-import org.onap.policy.apex.starter.exception.ApexStarterException;
+import org.onap.policy.apex.services.onappf.ApexStarterConstants;
+import org.onap.policy.apex.services.onappf.comm.PdpStatusPublisher;
+import org.onap.policy.apex.services.onappf.exception.ApexStarterException;
 import org.onap.policy.common.endpoints.event.comm.TopicSink;
 import org.onap.policy.common.utils.services.Registry;
 import org.onap.policy.models.pdp.concepts.PdpResponseDetails;
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter.parameters;
+package org.onap.policy.apex.services.onappf.parameters;
 
 import java.io.File;
 
-import org.onap.policy.apex.starter.ApexStarterCommandLineArguments;
-import org.onap.policy.apex.starter.exception.ApexStarterException;
+import org.onap.policy.apex.services.onappf.ApexStarterCommandLineArguments;
+import org.onap.policy.apex.services.onappf.exception.ApexStarterException;
 import org.onap.policy.common.parameters.GroupValidationResult;
 import org.onap.policy.common.utils.coder.Coder;
 import org.onap.policy.common.utils.coder.CoderException;
diff --git a/services/services-onappf/src/main/resources/config/OnapPfConfig.json b/services/services-onappf/src/main/resources/config/OnapPfConfig.json
new file mode 100644 (file)
index 0000000..5684f1d
--- /dev/null
@@ -0,0 +1,9 @@
+{
+    "name":"OnapPfParameterGroup",
+    "pdpStatusParameters":{
+        "timeIntervalMs": 120000,
+        "pdpType":"apex",
+        "description":"Pdp Heartbeat",
+        "supportedPolicyTypes":[{"name":"onap.policies.controlloop.Operational","version":"1.0.0"}]
+    }
+}
\ No newline at end of file
diff --git a/services/services-onappf/src/main/resources/config/topic.properties b/services/services-onappf/src/main/resources/config/topic.properties
new file mode 100644 (file)
index 0000000..b61626b
--- /dev/null
@@ -0,0 +1,23 @@
+# ============LICENSE_START=======================================================
+# Copyright (C) 2019 Nordix Foundation.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+
+dmaap.source.topics=POLICY-PDP-PAP
+dmaap.sink.topics=POLICY-PDP-PAP
+
+dmaap.source.topics.POLICY-PDP-PAP.servers= message-router
+dmaap.sink.topics.POLICY-PDP-PAP.servers= message-router
\ No newline at end of file
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter;
+package org.onap.policy.apex.services.onappf;
 
 import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
 import static org.junit.Assert.assertEquals;
@@ -33,10 +33,13 @@ import java.util.Properties;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.onap.policy.apex.starter.exception.ApexStarterException;
-import org.onap.policy.apex.starter.parameters.ApexStarterParameterGroup;
-import org.onap.policy.apex.starter.parameters.ApexStarterParameterHandler;
-import org.onap.policy.apex.starter.parameters.CommonTestData;
+import org.onap.policy.apex.services.onappf.ApexStarterActivator;
+import org.onap.policy.apex.services.onappf.ApexStarterCommandLineArguments;
+import org.onap.policy.apex.services.onappf.ApexStarterConstants;
+import org.onap.policy.apex.services.onappf.exception.ApexStarterException;
+import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterGroup;
+import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterHandler;
+import org.onap.policy.apex.services.onappf.parameters.CommonTestData;
 import org.onap.policy.common.utils.services.Registry;
 import org.onap.policy.models.pdp.concepts.PdpStatus;
 
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter;
+package org.onap.policy.apex.services.onappf;
 
 import org.junit.Test;
+import org.onap.policy.apex.services.onappf.ApexStarterConstants;
 import org.powermock.reflect.Whitebox;
 
 /**
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter;
+package org.onap.policy.apex.services.onappf;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -27,8 +27,11 @@ import static org.junit.Assert.assertTrue;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.onap.policy.apex.starter.exception.ApexStarterException;
-import org.onap.policy.apex.starter.parameters.CommonTestData;
+import org.onap.policy.apex.services.onappf.ApexStarterActivator;
+import org.onap.policy.apex.services.onappf.ApexStarterConstants;
+import org.onap.policy.apex.services.onappf.ApexStarterMain;
+import org.onap.policy.apex.services.onappf.exception.ApexStarterException;
+import org.onap.policy.apex.services.onappf.parameters.CommonTestData;
 import org.onap.policy.common.utils.services.Registry;
 
 /**
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter.comm;
+package org.onap.policy.apex.services.onappf.comm;
 
 import static org.junit.Assert.assertEquals;
 
@@ -37,12 +37,14 @@ import java.util.Properties;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.onap.policy.apex.starter.ApexStarterActivator;
-import org.onap.policy.apex.starter.ApexStarterCommandLineArguments;
-import org.onap.policy.apex.starter.ApexStarterConstants;
-import org.onap.policy.apex.starter.exception.ApexStarterException;
-import org.onap.policy.apex.starter.parameters.ApexStarterParameterGroup;
-import org.onap.policy.apex.starter.parameters.ApexStarterParameterHandler;
+import org.onap.policy.apex.services.onappf.ApexStarterActivator;
+import org.onap.policy.apex.services.onappf.ApexStarterCommandLineArguments;
+import org.onap.policy.apex.services.onappf.ApexStarterConstants;
+import org.onap.policy.apex.services.onappf.comm.PdpStateChangeListener;
+import org.onap.policy.apex.services.onappf.comm.PdpUpdateListener;
+import org.onap.policy.apex.services.onappf.exception.ApexStarterException;
+import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterGroup;
+import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterHandler;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.utils.services.Registry;
 import org.onap.policy.models.pdp.concepts.PdpStateChange;
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter.comm;
+package org.onap.policy.apex.services.onappf.comm;
 
 import static org.junit.Assert.assertEquals;
 
@@ -37,13 +37,14 @@ import java.util.Properties;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.onap.policy.apex.starter.ApexStarterActivator;
-import org.onap.policy.apex.starter.ApexStarterCommandLineArguments;
-import org.onap.policy.apex.starter.ApexStarterConstants;
-import org.onap.policy.apex.starter.exception.ApexStarterException;
-import org.onap.policy.apex.starter.handler.PdpMessageHandler;
-import org.onap.policy.apex.starter.parameters.ApexStarterParameterGroup;
-import org.onap.policy.apex.starter.parameters.ApexStarterParameterHandler;
+import org.onap.policy.apex.services.onappf.ApexStarterActivator;
+import org.onap.policy.apex.services.onappf.ApexStarterCommandLineArguments;
+import org.onap.policy.apex.services.onappf.ApexStarterConstants;
+import org.onap.policy.apex.services.onappf.comm.PdpUpdateListener;
+import org.onap.policy.apex.services.onappf.exception.ApexStarterException;
+import org.onap.policy.apex.services.onappf.handler.PdpMessageHandler;
+import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterGroup;
+import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterHandler;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.utils.services.Registry;
 import org.onap.policy.models.pdp.concepts.PdpStatus;
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter.exception;
+package org.onap.policy.apex.services.onappf.exception;
 
 import org.junit.Test;
+import org.onap.policy.apex.services.onappf.exception.ApexStarterException;
+import org.onap.policy.apex.services.onappf.exception.ApexStarterRunTimeException;
 import org.onap.policy.common.utils.test.ExceptionsTester;
 
 /**
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter.parameters;
+package org.onap.policy.apex.services.onappf.parameters;
 
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 
+import org.onap.policy.apex.services.onappf.parameters.ToscaPolicyTypeIdentifierParameters;
 import org.onap.policy.common.parameters.ParameterGroup;
 import org.onap.policy.common.utils.coder.Coder;
 import org.onap.policy.common.utils.coder.CoderException;
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter.parameters;
+package org.onap.policy.apex.services.onappf.parameters;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -100,7 +100,7 @@ public class TestApexStarterParameterGroup {
         final GroupValidationResult validationResult = apexStarterParameters.validate();
         assertFalse(validationResult.isValid());
         assertTrue(validationResult.getResult()
-                .contains("\"org.onap.policy.apex.starter.parameters.ApexStarterParameterGroup\" INVALID, "
+                .contains("\"org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterGroup\" INVALID, "
                         + "parameter group has status INVALID"));
     }
 }
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter.parameters;
+package org.onap.policy.apex.services.onappf.parameters;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
@@ -27,8 +27,10 @@ import static org.junit.Assert.fail;
 import java.io.FileNotFoundException;
 
 import org.junit.Test;
-import org.onap.policy.apex.starter.ApexStarterCommandLineArguments;
-import org.onap.policy.apex.starter.exception.ApexStarterException;
+import org.onap.policy.apex.services.onappf.ApexStarterCommandLineArguments;
+import org.onap.policy.apex.services.onappf.exception.ApexStarterException;
+import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterGroup;
+import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterHandler;
 import org.onap.policy.common.utils.coder.CoderException;
 
 /**
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.apex.starter.parameters;
+package org.onap.policy.apex.services.onappf.parameters;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
+import org.onap.policy.apex.services.onappf.parameters.PdpStatusParameters;
 import org.onap.policy.common.parameters.GroupValidationResult;
 
 /**
index 6b9df60..b1ea14d 100644 (file)
@@ -1,10 +1,9 @@
 {
     "name":"ApexStarterParameterGroup",
     "pdpStatusParameters":{
-        "timeIntervalMs": 2000,
-        "pdpName":"apex-pdp",
+        "timeIntervalMs": 120000,
         "pdpType":"apex",
         "description":"Pdp status for HealthCheck",
-        "supportedPolicyTypes":[{"name":"policy1","version":"1.0"},{"name":"policy2","version":"1.0"}]
+        "supportedPolicyTypes":[{"name":"onap.policies.controlloop.Operational","version":"1.0.0"}]
     }
-}
+}
\ No newline at end of file
index 87c6ebd..9f3c21d 100644 (file)
@@ -1,3 +1,21 @@
+# ============LICENSE_START=======================================================
+# Copyright (C) 2019 Nordix Foundation.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+
 noop.sink.topics=POLICY-PDP-PAP
 noop.sink.topics.POLICY-PDP-PAP.servers=anyserver
 noop.source.topics=POLICY-PDP-PAP