2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021 Nordix Foundation.
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.clamp.controlloop.common.handler;
23 import java.util.HashSet;
24 import java.util.List;
27 import lombok.NonNull;
28 import org.onap.policy.common.endpoints.event.comm.TopicSink;
29 import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
30 import org.onap.policy.common.utils.services.Registry;
31 import org.onap.policy.models.provider.PolicyModelsProviderParameters;
34 * Abstract class for handlers for sub components in the control loop system
36 * <p>Instances are effectively singletons that are started at system start.
38 public abstract class ControlLoopHandler {
40 private final PolicyModelsProviderParameters databaseProviderParameters;
45 * @param databaseProviderParameters the parameters for access to the database
47 protected ControlLoopHandler(@NonNull PolicyModelsProviderParameters databaseProviderParameters) {
48 this.databaseProviderParameters = databaseProviderParameters;
50 Registry.register(this.getClass().getName(), this);
54 Registry.unregister(this.getClass().getName());
58 * Get the provider classes that are used in instantiation.
60 * @return the provider classes
62 public Set<Class<?>> getProviderClasses() {
63 // No REST interfaces are the default
64 return new HashSet<>();
68 * Start any topic message listeners for this handler.
70 * @param msgDispatcher the message dispatcher with which to register the listener
72 public abstract void startAndRegisterListeners(MessageTypeDispatcher msgDispatcher);
75 * Start any topic message publishers for this handler.
77 * @param topicSinks the topic sinks on which the publisher can publish
79 public abstract void startAndRegisterPublishers(List<TopicSink> topicSinks);
82 * Stop any topic message publishers for this handler.
84 public abstract void stopAndUnregisterPublishers();
87 * Stop any topic message listeners for this handler.
89 * @param msgDispatcher the message dispatcher from which to unregister the listener
91 public abstract void stopAndUnregisterListeners(MessageTypeDispatcher msgDispatcher);