2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.apex.context.parameters;
24 import org.onap.policy.common.parameters.ParameterGroupImpl;
25 import org.onap.policy.common.parameters.annotations.ClassName;
26 import org.onap.policy.common.parameters.annotations.NotNull;
29 * A persistor parameter class that may be specialized by context persistor plugins that require
30 * plugin specific parameters.
32 * <p>The following parameters are defined:
34 * <li>pluginClass: the persistor plugin as the JVM local dummy ephemeral persistor
35 * <li>flushPeriod: Context is flushed to any persistor plugin that is defined periodically, and the
36 * period for flushing is the flush period.
39 * @author Liam Fallon (liam.fallon@ericsson.com)
42 public class PersistorParameters extends ParameterGroupImpl {
43 /** The default persistor is a dummy persistor that stubs the Persistor interface. */
44 public static final String DEFAULT_PERSISTOR_PLUGIN_CLASS =
45 "org.onap.policy.apex.context.impl.persistence.ephemeral.EphemeralPersistor";
47 /** Default periodic flushing interval, 5 minutes in milliseconds. */
48 public static final long DEFAULT_FLUSH_PERIOD = 300000;
50 private @ClassName String pluginClass = DEFAULT_PERSISTOR_PLUGIN_CLASS;
52 // Parameters for flushing
53 private long flushPeriod = DEFAULT_FLUSH_PERIOD;
56 * Constructor to create a persistor parameters instance and register the instance with the
59 public PersistorParameters() {
60 super(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
64 * Gets the plugin class.
66 * @return the plugin class
68 public String getPluginClass() {
73 * Sets the plugin class.
75 * @param pluginClass the plugin class
77 public void setPluginClass(final String pluginClass) {
78 this.pluginClass = pluginClass;
82 * Gets the flush period in milliseconds.
84 * @return the flush period
86 public long getFlushPeriod() {
91 * Sets the flush period in milliseconds.
93 * @param flushPeriod the flush period
95 public void setFlushPeriod(final long flushPeriod) {
96 if (flushPeriod <= 0) {
97 this.flushPeriod = DEFAULT_FLUSH_PERIOD;
99 this.flushPeriod = flushPeriod;
104 public String toString() {
105 return "PersistorParameters [name=" + getName() + ", pluginClass=" + pluginClass + ", flushPeriod="