2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.policy.drools.controller.internal;
23 import java.util.ArrayList;
24 import java.util.Collections;
25 import java.util.HashMap;
26 import java.util.List;
28 import org.onap.policy.common.endpoints.event.comm.TopicSink;
29 import org.onap.policy.drools.controller.DroolsController;
30 import org.onap.policy.drools.core.PolicyContainer;
31 import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration;
34 * no-op Drools Controller.
36 public class NullDroolsController implements DroolsController {
39 public boolean start() {
44 public boolean stop() {
49 public void shutdown() {
59 public boolean isAlive() {
64 public boolean lock() {
69 public boolean unlock() {
74 public boolean isLocked() {
79 public String getGroupId() {
84 public String getArtifactId() {
85 return NO_ARTIFACT_ID;
89 public String getVersion() {
94 public List<String> getSessionNames() {
95 return new ArrayList<>();
99 public List<String> getCanonicalSessionNames() {
100 return new ArrayList<>();
104 public List<String> getBaseDomainNames() {
105 return Collections.emptyList();
109 public boolean offer(String topic, String event) {
114 public boolean deliver(TopicSink sink, Object event) {
115 throw new IllegalStateException(makeInvokeMsg());
119 public Object[] getRecentSourceEvents() {
120 return new String[0];
124 public PolicyContainer getContainer() {
129 public String[] getRecentSinkEvents() {
130 return new String[0];
134 public boolean ownsCoder(Class<? extends Object> coderClass, int modelHash) {
135 throw new IllegalStateException(makeInvokeMsg());
139 public Class<?> fetchModelClass(String className) {
140 throw new IllegalArgumentException(makeInvokeMsg());
144 public boolean isBrained() {
149 public String toString() {
150 StringBuilder builder = new StringBuilder();
151 builder.append("NullDroolsController []");
152 return builder.toString();
156 public void updateToVersion(String newGroupId, String newArtifactId, String newVersion,
157 List<TopicCoderFilterConfiguration> decoderConfigurations,
158 List<TopicCoderFilterConfiguration> encoderConfigurations)
159 throws LinkageError {
160 throw new IllegalArgumentException(makeInvokeMsg());
164 public Map<String, Integer> factClassNames(String sessionName) {
165 return new HashMap<>();
169 public long factCount(String sessionName) {
174 public List<Object> facts(String sessionName, String className, boolean delete) {
175 return new ArrayList<>();
179 public List<Object> factQuery(String sessionName, String queryName,
180 String queriedEntity,
181 boolean delete, Object... queryParams) {
182 return new ArrayList<>();
185 private String makeInvokeMsg() {
186 return this.getClass().getCanonicalName() + " invoked";