[POLICY-72] replace openecomp for drools-pdp
[policy/drools-pdp.git] / policy-management / src / main / java / org / onap / policy / drools / features / PolicyControllerFeatureAPI.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * policy-management
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.drools.features;
22
23 import java.util.Properties;
24
25 import org.onap.policy.drools.event.comm.Topic.CommInfrastructure;
26 import org.onap.policy.drools.system.PolicyController;
27 import org.onap.policy.drools.utils.OrderedService;
28 import org.onap.policy.drools.utils.OrderedServiceImpl;
29
30 public interface PolicyControllerFeatureAPI extends OrderedService {
31
32           /**
33            * called before creating a controller with name 'name' and 
34            * properties 'properties'
35            * 
36            * @param name name of the the controller
37            * @param properties configuration properties
38            * 
39            * @return a policy controller.   A take over of the creation operation
40            * is performed by returning a non-null policy controller.   
41            * 'null' indicates that no take over has taken place, and processing should
42            * continue to the next feature provider.
43            */
44           public default PolicyController beforeCreate(String name, Properties properties) {return null;}
45
46           /**
47            * called after creating a controller with name 'name'
48            * 
49            * @param controller controller
50            * 
51            * @return true if this feature intercepts and takes ownership
52            * of the operation preventing the invocation of 
53            * lower priority features.   False, otherwise.
54            */
55           public default boolean afterCreate(PolicyController controller) {return false;}
56           
57           /**
58            * intercept before the Policy Controller is started.
59            * 
60            * @return true if this feature intercepts and takes ownership
61            * of the operation preventing the invocation of 
62            * lower priority features.   False, otherwise.
63            */
64           public default boolean beforeStart(PolicyController controller) {return false;}
65           
66           /**
67            * intercept after the Policy Controller is started.
68            * 
69            * @return true if this feature intercepts and takes ownership
70            * of the operation preventing the invocation of 
71            * lower priority features.   False, otherwise.
72            */
73           public default boolean afterStart(PolicyController controller) {return false;}
74           
75           /**
76            * intercept before the Policy Controller is stopped.
77            * 
78            * @return true if this feature intercepts and takes ownership
79            * of the operation preventing the invocation of 
80            * lower priority features.   False, otherwise..
81            */
82           public default boolean beforeStop(PolicyController controller) {return false;}
83           
84           /**
85            * intercept after the Policy Controller is stopped
86            * 
87            * @return true if this feature intercepts and takes ownership
88            * of the operation preventing the invocation of 
89            * lower priority features.   False, otherwise.d.
90            */
91           public default boolean afterStop(PolicyController controller) {return false;}
92           
93           /**
94            * intercept before the Policy Controller is locked
95            * 
96            * @return true if this feature intercepts and takes ownership
97            * of the operation preventing the invocation of 
98            * lower priority features.   False, otherwise.
99            */
100           public default boolean beforeLock(PolicyController controller) {return false;}
101           
102           /**
103            * intercept after the Policy Controller is locked
104            * 
105            * @return true if this feature intercepts and takes ownership
106            * of the operation preventing the invocation of 
107            * lower priority features.   False, otherwise..
108            */
109           public default boolean afterLock(PolicyController controller) {return false;}
110           
111           /**
112            * intercept before the Policy Controller is locked
113            * 
114            * @return true if this feature intercepts and takes ownership
115            * of the operation preventing the invocation of 
116            * lower priority features.   False, otherwise.
117            */
118           public default boolean beforeUnlock(PolicyController controller) {return false;}
119           
120           /**
121            * intercept after the Policy Controller is locked
122            * 
123            * @return true if this feature intercepts and takes ownership
124            * of the operation preventing the invocation of 
125            * lower priority features.   False, otherwise.
126            */
127           public default boolean afterUnlock(PolicyController controller) {return false;}
128           
129           /**
130            * intercept before the Policy Controller is shut down
131            * 
132            * @return true if this feature intercepts and takes ownership
133            * of the operation preventing the invocation of 
134            * lower priority features.   False, otherwise..
135            */
136           public default boolean beforeShutdown(PolicyController controller) {return false;}
137           
138           /**
139            * called after the Policy Controller is shut down
140            * 
141            * @return true if this feature intercepts and takes ownership
142            * of the operation preventing the invocation of 
143            * lower priority features.   False, otherwise.
144            */
145           public default boolean afterShutdown(PolicyController controller) {return false;}
146           
147           /**
148            * intercept before the Policy Controller is halted
149            * 
150            * @return true if this feature intercepts and takes ownership
151            * of the operation preventing the invocation of 
152            * lower priority features.   False, otherwise..
153            */
154           public default boolean beforeHalt(PolicyController controller) {return false;}
155           
156           /**
157            * called after the Policy Controller is halted
158            * 
159            * @return true if this feature intercepts and takes ownership
160            * of the operation preventing the invocation of 
161            * lower priority features.   False, otherwise.
162            */
163           public default boolean afterHalt(PolicyController controller) {return false;}
164           
165           
166           /**
167            * intercept before the Policy Controller is offered an event
168            * 
169            * @return true if this feature intercepts and takes ownership
170            * of the operation preventing the invocation of 
171            * lower priority features.   False, otherwise.
172            */
173           public default boolean beforeOffer(PolicyController controller,
174                                                      CommInfrastructure protocol,
175                                                      String topic,
176                                                      String event) {return false;}
177
178           /**
179            * called after the Policy Controller processes an event offer
180            * 
181            * @return true if this feature intercepts and takes ownership
182            * of the operation preventing the invocation of 
183            * lower priority features.   False, otherwise.
184            */
185           public default boolean afterOffer(PolicyController controller,
186                                         CommInfrastructure protocol,
187                                         String topic,
188                                         String event, 
189                                         boolean success) {return false;}
190           
191           /**
192            * intercept before the Policy Controller delivers (posts) an event
193            * 
194            * @return true if this feature intercepts and takes ownership
195            * of the operation preventing the invocation of 
196            * lower priority features.   False, otherwise.
197            */
198           public default boolean beforeDeliver(PolicyController controller,
199                                                                        CommInfrastructure protocol,
200                                                                        String topic,
201                                                                        Object event) {return false;}
202
203           /**
204            * called after the Policy Controller delivers (posts) an event
205            * 
206            * @return true if this feature intercepts and takes ownership
207            * of the operation preventing the invocation of 
208            * lower priority features.   False, otherwise.
209            */
210           public default boolean afterDeliver(PolicyController controller,
211                                                                       CommInfrastructure protocol,
212                                                                       String topic,
213                                                                       Object event, 
214                                                                       boolean success) {return false;}
215
216           
217           /**
218            * Feature providers implementing this interface
219            */
220           public static final OrderedServiceImpl<PolicyControllerFeatureAPI> providers = 
221                                                                         new OrderedServiceImpl<PolicyControllerFeatureAPI>(PolicyControllerFeatureAPI.class);
222 }