2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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.openecomp.policy.drools.event.comm.bus.internal;
23 import java.util.List;
25 import org.apache.commons.collections4.queue.CircularFifoQueue;
27 import org.openecomp.policy.drools.event.comm.Topic;
28 import org.openecomp.policy.drools.event.comm.bus.BusTopic;
30 public abstract class BusTopicBase implements BusTopic, Topic {
32 protected List<String> servers;
34 protected String topic;
36 protected String apiKey;
37 protected String apiSecret;
39 protected CircularFifoQueue<String> recentEvents = new CircularFifoQueue<String>(10);
41 public BusTopicBase(List<String> servers,
45 throws IllegalArgumentException {
47 if (servers == null || servers.isEmpty()) {
48 throw new IllegalArgumentException("UEB Server(s) must be provided");
51 if (topic == null || topic.isEmpty()) {
52 throw new IllegalArgumentException("An UEB Topic must be provided");
55 this.servers = servers;
59 this.apiSecret = apiSecret;
66 public String getTopic() {
74 public List<String> getServers() {
82 public String getApiKey() {
90 public String getApiSecret() {
95 * @return the recentEvents
98 public synchronized String[] getRecentEvents() {
99 String[] events = new String[recentEvents.size()];
100 return recentEvents.toArray(events);
105 public String toString() {
106 StringBuilder builder = new StringBuilder();
107 builder.append("UebTopicBase [servers=").append(servers).append(", topic=").append(topic).append(", apiKey=")
108 .append(apiKey).append(", apiSecret=").append(apiSecret).append("]");
109 return builder.toString();