2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 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.common.endpoints.event.comm.bus;
23 import java.util.List;
24 import org.onap.policy.common.endpoints.event.comm.bus.internal.TopicBase;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
29 * No Operation topic endpoint.
31 public abstract class NoopTopicEndpoint extends TopicBase {
36 private static Logger logger = LoggerFactory.getLogger(NoopTopicEndpoint.class);
41 private static final Logger netLogger = LoggerFactory.getLogger(NETWORK_LOGGER);
46 public NoopTopicEndpoint(List<String> servers, String topic) {
47 super(servers, topic);
53 * @param message message.
54 * @return true if sucessful.
56 protected boolean io(String message) {
58 if (message == null || message.isEmpty()) {
59 throw new IllegalArgumentException("Message is empty");
63 throw new IllegalStateException(this + " is stopped");
68 this.recentEvents.add(message);
71 netLogger.info("[OUT|{}|{}]{}{}", this.getTopicCommInfrastructure(), this.topic, System.lineSeparator(),
75 } catch (Exception e) {
76 logger.warn("{}: cannot send because of {}", this, e.getMessage(), e);
87 public CommInfrastructure getTopicCommInfrastructure() {
88 return CommInfrastructure.NOOP;
95 public boolean start() {
96 logger.info("{}: starting", this);
105 throw new IllegalStateException(this + " is locked.");
118 public boolean stop() {
119 logger.info("{}: stopping", this);
121 synchronized (this) {
131 public void shutdown() {
132 logger.info("{}: shutdown", this);
141 public String toString() {
142 return "NoopTopicEndpoint[" + super.toString() + "]";