2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.context.parameters;
23 import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
24 import org.onap.policy.apex.model.basicmodel.service.ParameterService;
27 * A persistor parameter class that may be specialized by context persistor plugins that require
28 * plugin specific parameters.
30 * <p>The following parameters are defined:
32 * <li>pluginClass: the persistor plugin as the JVM local dummy ephemeral persistor
33 * <li>flushPeriod: Context is flushed to any persistor plugin that is defined periodically, and the
34 * period for flushing is the flush period.
37 * @author Liam Fallon (liam.fallon@ericsson.com)
39 public class PersistorParameters extends AbstractParameters {
40 /** The default persistor is a dummy persistor that stubs the Persistor interface. */
41 public static final String DEFAULT_PERSISTOR_PLUGIN_CLASS =
42 "org.onap.policy.apex.context.impl.persistence.ephemeral.EphemeralPersistor";
44 /** Default periodic flushing interval, 5 minutes in milliseconds. */
45 public static final long DEFAULT_FLUSH_PERIOD = 300000;
48 private String pluginClass = DEFAULT_PERSISTOR_PLUGIN_CLASS;
50 // Parameters for flushing
51 private long flushPeriod = DEFAULT_FLUSH_PERIOD;
54 * Constructor to create a persistor parameters instance and register the instance with the
57 public PersistorParameters() {
58 super(PersistorParameters.class.getCanonicalName());
59 ParameterService.registerParameters(PersistorParameters.class, this);
63 * Constructor to create a persistor parameters instance with the name of a sub class of this
64 * class and register the instance with the parameter service.
66 * @param parameterClassName the class name of a sub class of this class
68 public PersistorParameters(final String parameterClassName) {
69 super(parameterClassName);
73 * Gets the plugin class.
75 * @return the plugin class
77 public String getPluginClass() {
82 * Sets the plugin class.
84 * @param pluginClass the plugin class
86 public void setPluginClass(final String pluginClass) {
87 this.pluginClass = pluginClass;
91 * Gets the flush period in milliseconds.
93 * @return the flush period
95 public long getFlushPeriod() {
100 * Sets the flush period in milliseconds.
102 * @param flushPeriod the flush period
104 public void setFlushPeriod(final long flushPeriod) {
105 if (flushPeriod <= 0) {
106 this.flushPeriod = DEFAULT_FLUSH_PERIOD;
108 this.flushPeriod = flushPeriod;
115 * @see org.onap.policy.apex.model.basicmodel.service.AbstractParameters#toString()
118 public String toString() {
119 return "PersistorParameters [pluginClass=" + pluginClass + ", flushPeriod=" + flushPeriod + "]";