2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.controlloop.actorserviceprovider.topic;
23 import java.util.List;
24 import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClient;
25 import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClientException;
28 * Handler for a bidirectional topic, supporting both publishing and forwarding of
31 public class BidirectionalTopicHandler extends BidirectionalTopicClient {
34 * Listener that will be attached to the topic to receive responses.
36 private final TopicListenerImpl listener = new TopicListenerImpl();
40 * Constructs the object.
42 * @param sinkTopic sink topic name
43 * @param sourceTopic source topic name
44 * @throws BidirectionalTopicClientException if an error occurs
46 public BidirectionalTopicHandler(String sinkTopic, String sourceTopic) throws BidirectionalTopicClientException {
47 super(sinkTopic, sourceTopic);
51 * Starts listening on the source topic(s).
54 getSource().register(listener);
58 * Stops listening on the source topic(s).
61 getSource().unregister(listener);
65 * Stops listening on the source topic(s) and clears all of the forwarders.
67 public void shutdown() {
72 public Forwarder addForwarder(SelectorKey... keys) {
73 return listener.addForwarder(keys);
76 public Forwarder addForwarder(List<SelectorKey> keys) {
77 return listener.addForwarder(keys);