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 plugin specific
30 * 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 period for flushing
34 * 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 parameter service.
56 public PersistorParameters() {
57 super(PersistorParameters.class.getCanonicalName());
58 ParameterService.registerParameters(PersistorParameters.class, this);
62 * Constructor to create a persistor parameters instance with the name of a sub class of this class and register the
63 * instance with the parameter service.
65 * @param parameterClassName the class name of a sub class of this class
67 public PersistorParameters(final String parameterClassName) {
68 super(parameterClassName);
72 * Gets the plugin class.
74 * @return the plugin class
76 public String getPluginClass() {
81 * Sets the plugin class.
83 * @param pluginClass the plugin class
85 public void setPluginClass(final String pluginClass) {
86 this.pluginClass = pluginClass;
90 * Gets the flush period in milliseconds.
92 * @return the flush period
94 public long getFlushPeriod() {
99 * Sets the flush period in milliseconds.
101 * @param flushPeriod the flush period
103 public void setFlushPeriod(final long flushPeriod) {
104 if (flushPeriod <= 0) {
105 this.flushPeriod = DEFAULT_FLUSH_PERIOD;
107 this.flushPeriod = flushPeriod;
114 * @see org.onap.policy.apex.model.basicmodel.service.AbstractParameters#toString()
117 public String toString() {
118 return "PersistorParameters [pluginClass=" + pluginClass + ", flushPeriod=" + flushPeriod + "]";