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