Fix sonar issues in drools-pdp
[policy/drools-pdp.git] / policy-core / src / main / java / org / onap / policy / drools / core / PolicySessionFeatureApi.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * policy-core
4  * ================================================================================
5  * Copyright (C) 2017-2019 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.core;
22
23 import org.kie.api.runtime.KieSession;
24 import org.onap.policy.common.utils.services.OrderedService;
25
26 /**
27  * This interface provides a way to invoke optional features at various
28  * points in the code. At appropriate points in the
29  * application, the code iterates through this list, invoking these optional
30  * methods. Most of the methods here are notification only -- these tend to
31  * return a 'void' value. In other cases, such as 'activatePolicySession',
32  * may
33  */
34 public interface PolicySessionFeatureApi extends OrderedService {
35
36     /**
37      * This method is called during initialization at a point right after
38      * 'PolicyContainer' initialization has completed.
39      *
40      * @param args standard 'main' arguments, which are currently ignored
41      * @param configDir the relative directory containing configuration files
42      */
43     public default void globalInit(String[] args, String configDir) {}
44
45     /**
46      * This method is used to create a 'KieSession' as part of a
47      * 'PolicyContainer'. The caller of this method will iterate over the
48      * implementers of this interface until one returns a non-null value.
49      *
50      * @param policyContainer the 'PolicyContainer' instance containing this
51      *     session
52      * @param name the name of the KieSession (which is also the name of
53      *     the associated PolicySession)
54      * @param kieBaseName the name of the 'KieBase' instance containing
55      *     this session
56      * @return a new KieSession, if one was created, or 'null' if not
57      *     (this depends on the capabilities and state of the object implementing
58      *     this interface)
59      */
60     public default KieSession activatePolicySession(PolicyContainer policyContainer, String name, String kieBaseName) {
61         return null;
62     }
63
64     /**
65      * This method is called after a new 'PolicySession' has been initialized,
66      * and linked to the 'PolicyContainer'.
67      *
68      * @param policySession the new 'PolicySession' instance
69      */
70     public default void newPolicySession(PolicySession policySession) {}
71
72     /**
73      * This method is called to select the 'ThreadModel' instance associated
74      * with a 'PolicySession' instance.
75      */
76     public default PolicySession.ThreadModel selectThreadModel(PolicySession session) {
77         return null;
78     }
79
80     /**
81      * This method is called after 'KieSession.dispose()' is called.
82      *
83      * @param policySession the 'PolicySession' object that wrapped the
84      *     'KieSession'
85      */
86     public default void disposeKieSession(PolicySession policySession) {}
87
88     /**
89      * This method is called after 'KieSession.destroy()' is called.
90      *
91      * @param policySession the 'PolicySession' object that wrapped the
92      *     'KieSession'
93      */
94     public default void destroyKieSession(PolicySession policySession) {}
95 }