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