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;
26 import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
28 public abstract class ApexPluginsEventProducer implements ApexEventProducer {
29 // The name for this producer
30 protected String name = null;
31 // The peer references for this event handler
32 protected Map<EventHandlerPeeredMode, PeeredReference> peerReferenceMap =
33 new EnumMap<>(EventHandlerPeeredMode.class);
39 public String getName() {
47 public PeeredReference getPeeredReference(final EventHandlerPeeredMode peeredMode) {
48 return peerReferenceMap.get(peeredMode);
55 public void setPeeredReference(final EventHandlerPeeredMode peeredMode, final PeeredReference peeredReference) {
56 peerReferenceMap.put(peeredMode, peeredReference);
63 public void sendEvent(final long executionId, final Properties executionProperties, final String eventName,
65 // Check if this is a synchronized event, if so we have received a reply
66 final SynchronousEventCache synchronousEventCache =
67 (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
68 if (synchronousEventCache != null) {
69 synchronousEventCache.removeCachedEventToApexIfExists(executionId);