3fef6fa9f35ec9c61c7316ef9edbaff8dd96ed9c
[policy/drools-pdp.git] /
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.controller.internal;
22
23 import java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.List;
26 import java.util.Map;
27
28 import org.onap.policy.drools.controller.DroolsController;
29 import org.onap.policy.drools.core.PolicyContainer;
30 import org.onap.policy.drools.event.comm.TopicSink;
31 import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration;
32
33 /**
34  * no-op Drools Controller
35  */
36 public class NullDroolsController implements DroolsController {
37
38         /**
39          * {@inheritDoc}
40          */
41         @Override
42         public boolean start() throws IllegalStateException {
43                 return false;
44         }
45
46         /**
47          * {@inheritDoc}
48          */
49         @Override
50         public boolean stop() throws IllegalStateException {
51                 return false;
52         }
53
54         /**
55          * {@inheritDoc}
56          */
57         @Override
58         public void shutdown() throws IllegalStateException {
59                 return;
60         }
61         
62         /**
63          * {@inheritDoc}
64          */
65         @Override
66         public void halt() throws IllegalStateException {
67                 return;
68         }
69
70         /**
71          * {@inheritDoc}
72          */
73         @Override
74         public boolean isAlive() {
75                 return false;
76         }
77
78         /**
79          * {@inheritDoc}
80          */
81         @Override
82         public boolean lock() {
83                 return false;
84         }
85
86         /**
87          * {@inheritDoc}
88          */
89         @Override
90         public boolean unlock() {
91                 return false;
92         }
93
94         /**
95          * {@inheritDoc}
96          */
97         @Override
98         public boolean isLocked() {
99                 return false;
100         }
101
102         /**
103          * {@inheritDoc}
104          */
105         @Override
106         public String getGroupId() {
107                 return NO_GROUP_ID;
108         }
109
110         /**
111          * {@inheritDoc}
112          */
113         @Override
114         public String getArtifactId() {
115                 return NO_ARTIFACT_ID;
116         }
117
118         /**
119          * {@inheritDoc}
120          */
121         @Override
122         public String getVersion() {
123                 return NO_VERSION;
124         }       
125
126         /**
127          * {@inheritDoc}
128          */
129         @Override
130         public List<String> getSessionNames() {
131                 return new ArrayList<String>();
132         }
133
134         /**
135          * {@inheritDoc}
136          */
137         @Override
138         public List<String> getCanonicalSessionNames() {
139                 return new ArrayList<String>();
140         }
141
142         /**
143          * {@inheritDoc}
144          */
145         @Override
146         public boolean offer(String topic, String event) {
147                 return false;
148         }
149
150         /**
151          * {@inheritDoc}
152          */
153         @Override
154         public boolean deliver(TopicSink sink, Object event)
155                         throws IllegalArgumentException, IllegalStateException, UnsupportedOperationException {
156                 throw new IllegalStateException(this.getClass().getCanonicalName() + " invoked");
157         }
158
159         /**
160          * {@inheritDoc}
161          */
162         @Override
163         public Object[] getRecentSourceEvents() {
164                 return new String[0];
165         }
166         
167         /**
168          * {@inheritDoc}
169          */
170         @Override
171         public PolicyContainer getContainer() {
172                 return null;
173         }
174
175         /**
176          * {@inheritDoc}
177          */
178         @Override
179         public String[] getRecentSinkEvents() {
180                 return new String[0];
181         }
182
183         /**
184          * {@inheritDoc}
185          */
186         @Override
187         public boolean ownsCoder(Class<? extends Object> coderClass, int modelHash) throws IllegalStateException {
188                 throw new IllegalStateException(this.getClass().getCanonicalName() + " invoked");
189         }
190
191         /**
192          * {@inheritDoc}
193          */
194         @Override
195         public Class<?> fetchModelClass(String className) throws IllegalArgumentException {
196                 throw new IllegalArgumentException(this.getClass().getCanonicalName() + " invoked");
197         }
198         
199         /**
200          * {@inheritDoc}
201          */
202         @Override
203         public boolean isBrained() {
204                 return false;
205         }
206         
207         /**
208          * {@inheritDoc}
209          */
210         @Override
211         public String toString() {
212                 StringBuilder builder = new StringBuilder();
213                 builder.append("NullDroolsController []");
214                 return builder.toString();
215         }
216
217         /**
218          * {@inheritDoc}
219          */
220         @Override
221         public void updateToVersion(String newGroupId, String newArtifactId, String newVersion,
222                         List<TopicCoderFilterConfiguration> decoderConfigurations,
223                         List<TopicCoderFilterConfiguration> encoderConfigurations)
224                         throws IllegalArgumentException, LinkageError, Exception {
225                 throw new IllegalArgumentException(this.getClass().getCanonicalName() + " invoked");
226         }
227
228         /**
229          * {@inheritDoc}
230          */
231         @Override
232         public Map<String, Integer> factClassNames(String sessionName) 
233                    throws IllegalArgumentException {
234                 return new HashMap<String,Integer>();
235         }
236
237         /**
238          * {@inheritDoc}
239          */
240         @Override
241         public long factCount(String sessionName) throws IllegalArgumentException {
242                 return 0;
243         }
244
245         /**
246          * {@inheritDoc}
247          */
248         @Override
249         public List<Object> facts(String sessionName, String className, boolean delete) {
250                 return new ArrayList<Object>();
251         }
252
253         /**
254          * {@inheritDoc}
255          */
256         @Override
257         public List<Object> factQuery(String sessionName, String queryName, 
258                                               String queriedEntity, 
259                                               boolean delete, Object... queryParams) {
260                 return new ArrayList<Object>();
261         }
262 }