2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020 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.apex.service.engine.event;
23 import java.util.EnumMap;
25 import java.util.Properties;
27 import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
29 public abstract class ApexPluginsEventProducer implements ApexEventProducer {
30 // The name for this producer
31 protected String name = null;
32 // The peer references for this event handler
33 protected Map<EventHandlerPeeredMode, PeeredReference> peerReferenceMap =
34 new EnumMap<>(EventHandlerPeeredMode.class);
40 public String getName() {
48 public PeeredReference getPeeredReference(final EventHandlerPeeredMode peeredMode) {
49 return peerReferenceMap.get(peeredMode);
56 public void setPeeredReference(final EventHandlerPeeredMode peeredMode, final PeeredReference peeredReference) {
57 peerReferenceMap.put(peeredMode, peeredReference);
64 public void sendEvent(final long executionId, final Properties executionProperties, final String eventName,
66 // Check if this is a synchronized event, if so we have received a reply
67 final SynchronousEventCache synchronousEventCache =
68 (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
69 if (synchronousEventCache != null) {
70 synchronousEventCache.removeCachedEventToApexIfExists(executionId);