aboutsummaryrefslogtreecommitdiffstats
path: root/context/context-management/src/main/java
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-08-30 09:37:29 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-08-31 19:23:41 +0100
commitf32508381ce0b555fc14978cbaa458aa4e2d91c5 (patch)
tree1cab66e5372b6467f288ae1351ce836e4eba2d03 /context/context-management/src/main/java
parent052038c7a7e0b385462b3b653b7d06094d472df3 (diff)
Use parameter service in apex
Switch parameter handling in apex to use the ONAP PF common parameter service Change-Id: Id318d19c726b18b1a69c630fa81ca7d695355e9c Issue-ID: POLICY-954 Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'context/context-management/src/main/java')
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java22
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java14
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java22
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java18
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java5
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameterConstants.java41
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameters.java41
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java46
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java46
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/PersistorParameters.java45
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaHelperParameters.java45
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaParameters.java29
12 files changed, 229 insertions, 145 deletions
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java
index 1af13cbea..dba81d321 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java
@@ -22,10 +22,11 @@ package org.onap.policy.apex.context.impl.distribution;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Distributor;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.model.utilities.Assertions;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -51,24 +52,23 @@ public class DistributorFactory {
Assertions.argumentNotNull(key, ContextException.class, "Parameter \"key\" may not be null");
// Get the class for the distributor using reflection
- final DistributorParameters distributorParameters = ParameterService.getParameters(DistributorParameters.class);
+ final DistributorParameters distributorParameters = ParameterService
+ .get(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
final String pluginClass = distributorParameters.getPluginClass();
Object contextDistributorObject = null;
try {
contextDistributorObject = Class.forName(pluginClass).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
- LOGGER.error(
- "Apex context distributor class not found for context distributor plugin \"" + pluginClass + "\"",
- e);
- throw new ContextException(
- "Apex context distributor class not found for context distributor plugin \"" + pluginClass + "\"",
- e);
+ LOGGER.error("Apex context distributor class not found for context distributor plugin \"" + pluginClass
+ + "\"", e);
+ throw new ContextException("Apex context distributor class not found for context distributor plugin \""
+ + pluginClass + "\"", e);
}
// Check the class is a distributor
if (!(contextDistributorObject instanceof Distributor)) {
final String returnString = "Specified Apex context distributor plugin class \"" + pluginClass
- + "\" does not implement the ContextDistributor interface";
+ + "\" does not implement the ContextDistributor interface";
LOGGER.error(returnString);
throw new ContextException(returnString);
}
@@ -79,8 +79,8 @@ public class DistributorFactory {
// Lock and load the context distributor
contextDistributor.init(key);
- LOGGER.exit(
- "Distributor factory, key=" + key + ", selected distributor of class " + contextDistributor.getClass());
+ LOGGER.exit("Distributor factory, key=" + key + ", selected distributor of class "
+ + contextDistributor.getClass());
return contextDistributor;
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java
index 467d43f9d..19bb3602e 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java
@@ -25,8 +25,9 @@ import java.util.TimerTask;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Distributor;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.PersistorParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -59,7 +60,8 @@ public class DistributorFlushTimerTask extends TimerTask {
this.contextDistributor = contextDistributor;
// Set the period for persistence flushing
- final PersistorParameters persistorParameters = ParameterService.getParameters(PersistorParameters.class);
+ final PersistorParameters persistorParameters = ParameterService
+ .get(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
period = persistorParameters.getFlushPeriod();
// Set up the timer
@@ -67,7 +69,7 @@ public class DistributorFlushTimerTask extends TimerTask {
timer.schedule(this, period, period);
LOGGER.debug("context distributor " + contextDistributor.getKey().getID() + " flushing set up with interval: "
- + period + "ms");
+ + period + "ms");
}
/**
@@ -79,14 +81,14 @@ public class DistributorFlushTimerTask extends TimerTask {
flushCount++;
LOGGER.debug("context distributor " + contextDistributor.getKey().getID() + " flushing: period=" + period
- + ": count=" + flushCount);
+ + ": count=" + flushCount);
try {
contextDistributor.flush();
LOGGER.debug("context distributor " + contextDistributor.getKey().getID() + " flushed: period=" + period
- + ": count=" + flushCount);
+ + ": count=" + flushCount);
} catch (final ContextException e) {
LOGGER.error("flush error on context distributor " + contextDistributor.getKey().getID() + ": period="
- + period + ": count=" + flushCount, e);
+ + period + ": count=" + flushCount, e);
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java
index f3f4a6240..c45e3bd27 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java
@@ -22,9 +22,10 @@ package org.onap.policy.apex.context.impl.locking;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.LockManager;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.LockManagerParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -48,7 +49,8 @@ public class LockManagerFactory {
public LockManager createLockManager(final AxArtifactKey key) throws ContextException {
LOGGER.entry("Lock Manager factory, key=" + key);
- final LockManagerParameters lockManagerParameters = ParameterService.getParameters(LockManagerParameters.class);
+ final LockManagerParameters lockManagerParameters = ParameterService
+ .get(ContextParameterConstants.LOCKING_GROUP_NAME);
// Get the class for the lock manager using reflection
Object lockManagerObject = null;
@@ -56,20 +58,18 @@ public class LockManagerFactory {
try {
lockManagerObject = Class.forName(pluginClass).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
- LOGGER.error(
- "Apex context lock manager class not found for context lock manager plugin \"" + pluginClass + "\"",
- e);
- throw new ContextException(
- "Apex context lock manager class not found for context lock manager plugin \"" + pluginClass + "\"",
- e);
+ LOGGER.error("Apex context lock manager class not found for context lock manager plugin \"" + pluginClass
+ + "\"", e);
+ throw new ContextException("Apex context lock manager class not found for context lock manager plugin \""
+ + pluginClass + "\"", e);
}
// Check the class is a lock manager
if (!(lockManagerObject instanceof LockManager)) {
- LOGGER.error("Specified Apex context lock manager plugin class \"" + pluginClass
- + "\" does not implement the LockManager interface");
+ LOGGER.error("Specified Apex context lock manager plugin class \"{}\" does not implement the LockManager interface",
+ pluginClass);
throw new ContextException("Specified Apex context lock manager plugin class \"" + pluginClass
- + "\" does not implement the LockManager interface");
+ + "\" does not implement the LockManager interface");
}
// The context lock manager to return
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java
index af6f922d3..34fa15dcb 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java
@@ -22,10 +22,11 @@ package org.onap.policy.apex.context.impl.persistence;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Persistor;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.PersistorParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.model.utilities.Assertions;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -49,7 +50,8 @@ public class PersistorFactory {
LOGGER.entry("persistor factory, key=" + key);
Assertions.argumentNotNull(key, ContextException.class, "Parameter \"key\" may not be null");
- final PersistorParameters persistorParameters = ParameterService.getParameters(PersistorParameters.class);
+ final PersistorParameters persistorParameters = ParameterService
+ .get(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
// Get the class for the persistor using reflection
Object persistorObject = null;
@@ -58,17 +60,17 @@ public class PersistorFactory {
persistorObject = Class.forName(pluginClass).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
LOGGER.error("Apex context persistor class not found for context persistor plugin \"" + pluginClass + "\"",
- e);
- throw new ContextException(
- "Apex context persistor class not found for context persistor plugin \"" + pluginClass + "\"", e);
+ e);
+ throw new ContextException("Apex context persistor class not found for context persistor plugin \""
+ + pluginClass + "\"", e);
}
// Check the class is a persistor
if (!(persistorObject instanceof Persistor)) {
- LOGGER.error("Specified Apex context persistor plugin class \"" + pluginClass
- + "\" does not implement the ContextDistributor interface");
+ LOGGER.error("Specified Apex context persistor plugin class \"{}\" does not implement the ContextDistributor interface",
+ pluginClass);
throw new ContextException("Specified Apex context persistor plugin class \"" + pluginClass
- + "\" does not implement the ContextDistributor interface");
+ + "\" does not implement the ContextDistributor interface");
}
// The persistor to return
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java
index 54689e3fb..84025fc25 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java
@@ -22,15 +22,16 @@ package org.onap.policy.apex.context.impl.schema;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.context.SchemaHelper;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaHelperParameters;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.Assertions;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -67,7 +68,7 @@ public class SchemaHelperFactory {
}
// Get the schema class using the parameter service
- final SchemaParameters schemaParameters = ParameterService.getParameters(SchemaParameters.class);
+ final SchemaParameters schemaParameters = ParameterService.get(ContextParameterConstants.SCHEMA_GROUP_NAME);
// Get the class for the schema helper from the schema parameters
final SchemaHelperParameters schemaHelperParameters =
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameterConstants.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameterConstants.java
new file mode 100644
index 000000000..af712706d
--- /dev/null
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameterConstants.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package org.onap.policy.apex.context.parameters;
+
+/**
+ * This class holds constants used when managing context parameter groups in apex.
+ */
+public abstract class ContextParameterConstants {
+ public static final String MAIN_GROUP_NAME = "CONTEXT_PARAMETERS";
+ public static final String SCHEMA_GROUP_NAME = "CONTEXT_SCHEMA_PARAMETERS";
+ public static final String SCHEMA_HELPER_GROUP_NAME = "CONTEXT_SCHEMA_HELPER_PARAMETERS";
+ public static final String DISTRIBUTOR_GROUP_NAME = "CONTEXT_DISTRIBUTOR_PARAMETERS";
+ public static final String LOCKING_GROUP_NAME = "CONTEXT_LOCKING_PARAMETERS";
+ public static final String PERSISTENCE_GROUP_NAME = "CONTEXT_PERSISTENCE_PARAMETERS";
+
+ /**
+ * Private default constructor to prevent subclassing
+ */
+ private ContextParameterConstants() {
+ // Prevents subclassing
+ }
+
+}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameters.java
index 8bda76d21..2a109d48f 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameters.java
@@ -20,8 +20,8 @@
package org.onap.policy.apex.context.parameters;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* Bean class to hold parameters for context handling in Apex. This class contains all the context
@@ -43,9 +43,10 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ContextParameters extends AbstractParameters {
+public class ContextParameters implements ParameterGroup {
// @formatter:off
// Plugin Parameters
+ private String name;
private DistributorParameters distributorParameters = new DistributorParameters();
private SchemaParameters schemaParameters = new SchemaParameters();
private LockManagerParameters lockManagerParameters = new LockManagerParameters();
@@ -57,8 +58,10 @@ public class ContextParameters extends AbstractParameters {
* parameter service.
*/
public ContextParameters() {
- super(ContextParameters.class.getCanonicalName());
- ParameterService.registerParameters(ContextParameters.class, this);
+ super();
+
+ // Set the name for the parameters
+ this.name = ContextParameterConstants.MAIN_GROUP_NAME;
}
/**
@@ -132,16 +135,26 @@ public class ContextParameters extends AbstractParameters {
public void setPersistorParameters(final PersistorParameters persistorParameters) {
this.persistorParameters = persistorParameters;
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.service.AbstractParameters#toString()
- */
+
@Override
public String toString() {
- return "ContextParameters [distributorParameters=" + distributorParameters + ", schemaParameters="
- + schemaParameters + ", lockManagerParameters=" + lockManagerParameters + ", persistorParameters="
- + persistorParameters + "]";
+ return "ContextParameters [name=" + name + ", distributorParameters=" + distributorParameters
+ + ", schemaParameters=" + schemaParameters + ", lockManagerParameters=" + lockManagerParameters
+ + ", persistorParameters=" + persistorParameters + "]";
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java
index cb4c6128e..e3f58cae4 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/DistributorParameters.java
@@ -21,8 +21,8 @@
package org.onap.policy.apex.context.parameters;
import org.onap.policy.apex.context.impl.distribution.jvmlocal.JVMLocalDistributor;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* An empty distributor parameter class that may be specialized by context distributor plugins that
@@ -31,11 +31,11 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class DistributorParameters extends AbstractParameters {
+public class DistributorParameters implements ParameterGroup {
/** The default distributor makes context albums available to all threads in a single JVM. */
public static final String DEFAULT_DISTRIBUTOR_PLUGIN_CLASS = JVMLocalDistributor.class.getCanonicalName();
- // Plugin class names
+ private String name;
private String pluginClass = DEFAULT_DISTRIBUTOR_PLUGIN_CLASS;
/**
@@ -43,18 +43,10 @@ public class DistributorParameters extends AbstractParameters {
* parameter service.
*/
public DistributorParameters() {
- super(DistributorParameters.class.getCanonicalName());
- ParameterService.registerParameters(DistributorParameters.class, this);
- }
-
- /**
- * Constructor to create a distributor parameters instance with the name of a sub class of this
- * class and register the instance with the parameter service.
- *
- * @param parameterClassName the class name of a sub class of this class
- */
- public DistributorParameters(final String parameterClassName) {
- super(parameterClassName);
+ super();
+
+ // Set the name for the parameters
+ this.name = ContextParameterConstants.DISTRIBUTOR_GROUP_NAME;
}
/**
@@ -75,13 +67,23 @@ public class DistributorParameters extends AbstractParameters {
this.pluginClass = pluginClass;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.service.AbstractParameters#toString()
- */
@Override
public String toString() {
- return "DistributorParameters [pluginClass=" + pluginClass + "]";
+ return "DistributorParameters [name=" + name + ", pluginClass=" + pluginClass + "]";
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java
index 1aaee2cc7..27fc05a0b 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/LockManagerParameters.java
@@ -21,8 +21,8 @@
package org.onap.policy.apex.context.parameters;
import org.onap.policy.apex.context.impl.locking.jvmlocal.JVMLocalLockManager;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* An empty lock manager parameter class that may be specialized by context lock manager plugins
@@ -31,13 +31,13 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class LockManagerParameters extends AbstractParameters {
+public class LockManagerParameters implements ParameterGroup {
/**
* The default lock manager can lock context album instance across all threads in a single JVM.
*/
public static final String DEFAULT_LOCK_MANAGER_PLUGIN_CLASS = JVMLocalLockManager.class.getCanonicalName();
- // Plugin class names
+ private String name;
private String pluginClass = DEFAULT_LOCK_MANAGER_PLUGIN_CLASS;
/**
@@ -45,18 +45,10 @@ public class LockManagerParameters extends AbstractParameters {
* parameter service.
*/
public LockManagerParameters() {
- super(LockManagerParameters.class.getCanonicalName());
- ParameterService.registerParameters(LockManagerParameters.class, this);
- }
+ super();
- /**
- * Constructor to create a lock manager parameters instance with the name of a sub class of this
- * class and register the instance with the parameter service.
- *
- * @param parameterClassName the class name of a sub class of this class
- */
- public LockManagerParameters(final String parameterClassName) {
- super(parameterClassName);
+ // Set the name for the parameters
+ this.name = ContextParameterConstants.LOCKING_GROUP_NAME;
}
/**
@@ -76,14 +68,24 @@ public class LockManagerParameters extends AbstractParameters {
public void setPluginClass(final String pluginClass) {
this.pluginClass = pluginClass;
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.service.AbstractParameters#toString()
- */
+
@Override
public String toString() {
- return "LockManagerParameters [pluginClass=" + pluginClass + "]";
+ return "LockManagerParameters [name=" + name + ", pluginClass=" + pluginClass + "]";
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/PersistorParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/PersistorParameters.java
index 6fd320001..3616b526e 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/PersistorParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/PersistorParameters.java
@@ -20,8 +20,8 @@
package org.onap.policy.apex.context.parameters;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* A persistor parameter class that may be specialized by context persistor plugins that require
@@ -36,7 +36,7 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class PersistorParameters extends AbstractParameters {
+public class PersistorParameters implements ParameterGroup {
/** The default persistor is a dummy persistor that stubs the Persistor interface. */
public static final String DEFAULT_PERSISTOR_PLUGIN_CLASS =
"org.onap.policy.apex.context.impl.persistence.ephemeral.EphemeralPersistor";
@@ -44,7 +44,7 @@ public class PersistorParameters extends AbstractParameters {
/** Default periodic flushing interval, 5 minutes in milliseconds. */
public static final long DEFAULT_FLUSH_PERIOD = 300000;
- // Plugin class names
+ private String name;
private String pluginClass = DEFAULT_PERSISTOR_PLUGIN_CLASS;
// Parameters for flushing
@@ -55,18 +55,10 @@ public class PersistorParameters extends AbstractParameters {
* parameter service.
*/
public PersistorParameters() {
- super(PersistorParameters.class.getCanonicalName());
- ParameterService.registerParameters(PersistorParameters.class, this);
- }
+ super();
- /**
- * Constructor to create a persistor parameters instance with the name of a sub class of this
- * class and register the instance with the parameter service.
- *
- * @param parameterClassName the class name of a sub class of this class
- */
- public PersistorParameters(final String parameterClassName) {
- super(parameterClassName);
+ // Set the name for the parameters
+ this.name = ContextParameterConstants.PERSISTENCE_GROUP_NAME;
}
/**
@@ -109,13 +101,24 @@ public class PersistorParameters extends AbstractParameters {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.service.AbstractParameters#toString()
- */
@Override
public String toString() {
- return "PersistorParameters [pluginClass=" + pluginClass + ", flushPeriod=" + flushPeriod + "]";
+ return "PersistorParameters [name=" + name + ", pluginClass=" + pluginClass + ", flushPeriod=" + flushPeriod
+ + "]";
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaHelperParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaHelperParameters.java
index 9ccd431a5..e2bb4d6b9 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaHelperParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaHelperParameters.java
@@ -20,8 +20,8 @@
package org.onap.policy.apex.context.parameters;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* An empty schema helper parameter class that may be specialized by context schema helper plugins that require plugin
@@ -29,26 +29,15 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class SchemaHelperParameters extends AbstractParameters {
- // Schema helper plugin class for the schema
+public class SchemaHelperParameters implements ParameterGroup {
+ private String name;
private String schemaHelperPluginClass;
/**
* Constructor to create a schema helper parameters instance and register the instance with the parameter service.
*/
public SchemaHelperParameters() {
- super(SchemaHelperParameters.class.getCanonicalName());
- ParameterService.registerParameters(SchemaHelperParameters.class, this);
- }
-
- /**
- * Constructor to create a schema helper parameters instance with the name of a sub class of this class and register
- * the instance with the parameter service.
- *
- * @param parameterClassName the class name of a sub class of this class
- */
- public SchemaHelperParameters(final String parameterClassName) {
- super(parameterClassName);
+ super();
}
/**
@@ -68,14 +57,24 @@ public class SchemaHelperParameters extends AbstractParameters {
public void setSchemaHelperPluginClass(final String pluginClass) {
schemaHelperPluginClass = pluginClass;
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.service.AbstractParameters#toString()
- */
+
@Override
public String toString() {
- return "SchemaHelperParameters [schemaHelperPluginClass=" + schemaHelperPluginClass + "]";
+ return "SchemaHelperParameters [name=" + name + ", schemaHelperPluginClass=" + schemaHelperPluginClass + "]";
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
}
}
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaParameters.java b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaParameters.java
index 12e203c30..9992b9f3c 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaParameters.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaParameters.java
@@ -24,8 +24,8 @@ import java.util.Map;
import java.util.TreeMap;
import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
-import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
/**
* Bean class holding schema parameters for schemas and their helpers. As more than one schema can
@@ -38,10 +38,12 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class SchemaParameters extends AbstractParameters {
+public class SchemaParameters implements ParameterGroup {
/** The Java schema flavour is always available for use. */
public static final String DEFAULT_SCHEMA_FLAVOUR = "Java";
+ private String name;
+
// A map of parameters for executors of various logic types
private Map<String, SchemaHelperParameters> schemaHelperParameterMap;
@@ -50,8 +52,10 @@ public class SchemaParameters extends AbstractParameters {
* parameter service.
*/
public SchemaParameters() {
- super(SchemaParameters.class.getCanonicalName());
- ParameterService.registerParameters(SchemaParameters.class, this);
+ super();
+
+ // Set the name for the parameters
+ this.name = ContextParameterConstants.SCHEMA_GROUP_NAME;
schemaHelperParameterMap = new TreeMap<>();
@@ -86,4 +90,19 @@ public class SchemaParameters extends AbstractParameters {
public SchemaHelperParameters getSchemaHelperParameters(final String schemaFlavour) {
return schemaHelperParameterMap.get(schemaFlavour);
}
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
+ }
}