diff options
author | 2022-02-07 17:56:44 +0000 | |
---|---|---|
committer | 2022-02-08 18:39:03 +0000 | |
commit | 59b90519eda3b95b0cfc49b6349a591c7d0c78e2 (patch) | |
tree | 810e07f7d5cf270582264c40245372f597c713a2 /model/engine-model | |
parent | def44b294fa00bb5470e977eef9a05e5087035f0 (diff) |
Remove JAXB and XML, use GSON for JSON
This review converst apex-pdp to use GSON for JSON handling. In order to
preserve backward compatibility with the JAXB format of JSON, custom
handling of maps was required. Therefore, the policy-common
StandardCoder could not be used.
There are a lot of small changes, removing annotations from concepts and
tweaking of test data. However, this cleans up the code base so it is
worth doing.
Issue-ID: POLICY-1820
Change-Id: I213fa64f6d7f3f1df8d10f111d9fbedbe80f9fe0
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'model/engine-model')
6 files changed, 9 insertions, 85 deletions
diff --git a/model/engine-model/pom.xml b/model/engine-model/pom.xml index 7a1b485f8..9db1b2053 100644 --- a/model/engine-model/pom.xml +++ b/model/engine-model/pom.xml @@ -2,6 +2,7 @@ ============LICENSE_START======================================================= Copyright (C) 2018 Ericsson. All rights reserved. Modifications Copyright (C) 2022 Bell Canada. + Modifications Copyright (C) 2022 Nordix Foundation. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -41,30 +42,4 @@ <artifactId>simpleclient</artifactId> </dependency> </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <executions> - <execution> - <id>generate-xml-schema</id> - <phase>process-classes</phase> - <goals> - <goal>java</goal> - </goals> - <configuration> - <mainClass>org.onap.policy.apex.model.basicmodel.handling.ApexSchemaGenerator</mainClass> - <classpathScope>compile</classpathScope> - <arguments> - <argument>org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel</argument> - <argument>${project.build.directory}/model/xml/apex-engine-model.xsd</argument> - </arguments> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project>
\ No newline at end of file +</project> diff --git a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineModel.java b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineModel.java index 97e85c596..1a590a411 100644 --- a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineModel.java +++ b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineModel.java @@ -24,11 +24,6 @@ package org.onap.policy.apex.model.enginemodel.concepts; import java.text.SimpleDateFormat; import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.basicmodel.concepts.AxConcept; import org.onap.policy.apex.model.basicmodel.concepts.AxKey; @@ -53,20 +48,12 @@ import org.onap.policy.common.utils.validation.Assertions; * <p>Validation checks that the current state {@link AxEngineState} is defined and that the time stamp * is set on the engine model. */ -@XmlRootElement(name = "apexEngineModel", namespace = "http://www.onap.org/policy/apex-pdp") -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "AxEngineModel", namespace = "http://www.onap.org/policy/apex-pdp", - propOrder = {"timestamp", "state", "stats"}) - public class AxEngineModel extends AxContextModel { private static final long serialVersionUID = 6381235864606564046L; private static final int HASH_CODE_PRIME = 32; private long timestamp; - - @XmlElement(required = true) private AxEngineState state; - private AxEngineStats stats; /** diff --git a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineState.java b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineState.java index 63c8706d2..24c564b96 100644 --- a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineState.java +++ b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineState.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,18 +22,12 @@ package org.onap.policy.apex.model.enginemodel.concepts; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlType; - /** * This enumeration indicates the execution state of an Apex engine. * * @author Liam Fallon (liam.fallon@ericsson.com) */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "AxEngineState", namespace = "http://www.onap.org/policy/apex-pdp") public enum AxEngineState { /** The state of the engine is not known. */ UNDEFINED(0), @@ -54,4 +49,4 @@ public enum AxEngineState { public int getStateIdentifier() { return stateIdentifier; } -}
\ No newline at end of file +} diff --git a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineStats.java b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineStats.java index af5e8d458..36df645a5 100644 --- a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineStats.java +++ b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineStats.java @@ -26,11 +26,6 @@ import io.prometheus.client.Gauge; import io.prometheus.client.Histogram; import java.text.SimpleDateFormat; import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; import lombok.Getter; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.basicmodel.concepts.AxConcept; @@ -47,10 +42,6 @@ import org.onap.policy.common.utils.validation.Assertions; * engine, and the time stamp of the last engine start are recorded. */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlRootElement(name = "apexEngineStats", namespace = "http://www.onap.org/policy/apex-pdp") -@XmlType(name = "AxEngineStats", namespace = "http://www.onap.org/policy/apex-pdp", propOrder = {"key", "timeStamp", - "eventCount", "lastExecutionTime", "averageExecutionTime", "upTime", "lastStart"}) public class AxEngineStats extends AxConcept { private static final long serialVersionUID = -6981129081962785368L; private static final int HASH_CODE_PRIME = 32; @@ -71,28 +62,15 @@ public class AxEngineStats extends AxConcept { .name("apex_engine_last_execution_time").labelNames(ENGINE_INSTANCE_ID) .help("Time taken to execute the last APEX policy in seconds.").register(); - @XmlElement(name = "key", required = true) private AxReferenceKey key; - - @XmlElement(required = true) private long timeStamp; - - @XmlElement(required = true) private long eventCount; - - @XmlElement(required = true) private long lastExecutionTime; - - @XmlElement(required = true) private double averageExecutionTime; - - @XmlElement(required = true) private long upTime; @Getter private transient long lastEnterTime; - - @XmlElement(required = true) private long lastStart; /** diff --git a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/package-info.java b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/package-info.java index ea47c6993..4557af7db 100644 --- a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/package-info.java +++ b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/package-info.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2022 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========================================================= */ @@ -21,14 +22,7 @@ /** * Contains the concepts required to receive state information and statistcs from running APEX * engines. - * + * * @author Liam Fallon (liam.fallon@ericsson.com) */ -@XmlSchema(namespace = "http://www.onap.org/policy/apex-pdp", elementFormDefault = XmlNsForm.QUALIFIED, - xmlns = {@XmlNs(namespaceURI = "http://www.onap.org/policy/apex-pdp", prefix = "")}) - package org.onap.policy.apex.model.enginemodel.concepts; - -import javax.xml.bind.annotation.XmlNs; -import javax.xml.bind.annotation.XmlNsForm; -import javax.xml.bind.annotation.XmlSchema; diff --git a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java index 8baa59b2f..e7fdd2d93 100644 --- a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java +++ b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java @@ -75,11 +75,6 @@ public class ApexEngineModelTest { } @Test - public void testModelWriteReadXml() throws Exception { - testApexModel.testApexModelWriteReadXml(); - } - - @Test public void testModelWriteReadJson() throws Exception { testApexModel.testApexModelWriteReadJson(); } |