2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.sli.core.sli.provider.base;
24 import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor;
25 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
26 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
27 import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
28 import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
29 import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder;
30 import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 public abstract class AbstractSvcLogicNodeExecutor {
35 protected SvcLogicResolver resolver;
36 public abstract SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException;
38 private static final Logger LOG = LoggerFactory.getLogger(AbstractSvcLogicNodeExecutor.class);
40 protected String evaluateNodeTest(SvcLogicNode node, SvcLogicContext ctx)
41 throws SvcLogicException {
46 return (SvcLogicExpressionResolver.evaluate(node.getAttribute("test"),
51 public void setResolver(SvcLogicResolver resolver) {
52 this.resolver = resolver;
55 protected SvcLogicAdaptor getAdaptor(String adaptorName) {
56 return resolver.getSvcLogicAdaptor(adaptorName);
59 protected SvcLogicResource getSvcLogicResource(String resourceName) {
60 return resolver.getSvcLogicResource(resourceName);
63 protected SvcLogicRecorder getSvcLogicRecorder(String recorderName) {
64 return resolver.getSvcLogicRecorder(recorderName);
67 protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName){
68 return resolver.getSvcLogicJavaPlugin(pluginName);
71 protected SvcLogicNode getNextNode(SvcLogicNode node, String outValue) {
72 SvcLogicNode nextNode = node.getOutcomeValue(outValue);
73 if (nextNode != null) {
74 if (LOG.isDebugEnabled()) {
75 LOG.debug("about to execute " + outValue + " branch");
80 nextNode = node.getOutcomeValue("Other");
81 if (nextNode != null) {
82 if (LOG.isDebugEnabled()) {
83 LOG.debug("about to execute Other branch");
86 if (LOG.isDebugEnabled()) {
87 LOG.debug("no " + outValue + " or Other branch found");