1d64768379ddaa0f308bda2ceb896b88637b7097
[policy/apex-pdp.git] / services / services-engine / src / main / java / org / onap / policy / apex / service / engine / event / ApexEventProducer.java
1 /*-
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.apex.service.engine.event;
22
23 import java.util.Properties;
24
25 import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
26 import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
27
28 /**
29  * This interface is used by technology specific producers and publishers that are handling events
30  * output by Apex. Users specify the producer technology to use in the Apex configuration and Apex
31  * uses a factory to start the appropriate producer plugin that implements this interface for its
32  * output. The technology specific implementation details are hidden behind this interface.
33  *
34  * @author Liam Fallon (liam.fallon@ericsson.com)
35  */
36 public interface ApexEventProducer {
37
38     /**
39      * Initialize the producer.
40      *
41      * @param name a name for this producer
42      * @param producerParameters the parameters to initialise this producer
43      * @throws ApexEventException exception on errors initializing an event producer
44      */
45     void init(String name, EventHandlerParameters producerParameters) throws ApexEventException;
46
47     /**
48      * Get the peered reference object for this producer.
49      *
50      * @param peeredMode the peered mode for which to return the reference
51      * @return the peered reference object for this producer
52      */
53     PeeredReference getPeeredReference(EventHandlerPeeredMode peeredMode);
54
55     /**
56      * Set the peered reference object for this producer.
57      *
58      * @param peeredMode the peered mode for which to return the reference
59      * @param peeredReference the peered reference object for this producer
60      */
61     void setPeeredReference(EventHandlerPeeredMode peeredMode, PeeredReference peeredReference);
62
63     /**
64      * Send an event to the producer.
65      *
66      * @param executionId the unique ID that produced this event
67      * @param executionProperties properties used during processing of this event
68      * @param eventName The name of the event
69      * @param event The converted event as an object
70      */
71     void sendEvent(long executionId, Properties executionProperties, String eventName, Object event);
72
73     /**
74      * Get the name of this event producer.
75      *
76      * @return the event producer name
77      */
78     String getName();
79
80     /**
81      * Stop the event producer.
82      */
83     void stop();
84 }