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.service.engine.event;
23 import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
26 * This class holds a reference to an event consumer and producer that have been peered.
28 * @author Liam Fallon (liam.fallon@ericsson.com)
30 public class PeeredReference {
31 // The consumer putting events into APEX
32 private final ApexEventConsumer peeredConsumer;
34 // The synchronous producer taking events out of APEX
35 private final ApexEventProducer peeredProducer;
38 * Create a peered consumer/producer reference
40 * @param peeredMode the peered mode for which to return the reference
41 * @param consumer the consumer that is receiving event
42 * @param producer the producer that is sending events
44 public PeeredReference(final EventHandlerPeeredMode peeredMode, final ApexEventConsumer consumer, final ApexEventProducer producer) {
45 this.peeredConsumer = consumer;
46 this.peeredProducer = producer;
48 // Set the peered reference on the producer and consumer
49 peeredConsumer.setPeeredReference(peeredMode, this);
50 peeredProducer.setPeeredReference(peeredMode, this);
54 * Gets the synchronous consumer putting events into the cache.
56 * @return the source synchronous consumer
58 public ApexEventConsumer getPeeredConsumer() {
59 return peeredConsumer;
63 * Gets the synchronous producer taking events from the cache.
65 * @return the synchronous producer that is taking events from the cache
67 public ApexEventProducer getPeeredProducer() {
68 return peeredProducer;