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.MetricLogger;
25 import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor;
26 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
27 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
28 import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
29 import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
30 import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder;
31 import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
35 public abstract class AbstractSvcLogicNodeExecutor {
36 protected SvcLogicResolver resolver;
37 public abstract SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException;
39 private static final Logger LOG = LoggerFactory.getLogger(AbstractSvcLogicNodeExecutor.class);
41 protected String evaluateNodeTest(SvcLogicNode node, SvcLogicContext ctx)
42 throws SvcLogicException {
47 return (SvcLogicExpressionResolver.evaluate(node.getAttribute("test"),
52 public void setResolver(SvcLogicResolver resolver) {
53 this.resolver = resolver;
56 protected SvcLogicAdaptor getAdaptor(String adaptorName) {
57 return resolver.getSvcLogicAdaptor(adaptorName);
60 protected SvcLogicResource getSvcLogicResource(String resourceName) {
61 return resolver.getSvcLogicResource(resourceName);
64 protected SvcLogicRecorder getSvcLogicRecorder(String recorderName) {
65 return resolver.getSvcLogicRecorder(recorderName);
68 protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName){
69 return resolver.getSvcLogicJavaPlugin(pluginName);
72 protected SvcLogicNode getNextNode(SvcLogicNode node, String outValue) {
73 MetricLogger.resetContext();
74 SvcLogicNode nextNode = node.getOutcomeValue(outValue);
75 if (nextNode != null) {
76 if (LOG.isDebugEnabled()) {
77 LOG.debug("about to execute " + outValue + " branch");
82 nextNode = node.getOutcomeValue("Other");
83 if (nextNode != null) {
84 if (LOG.isDebugEnabled()) {
85 LOG.debug("about to execute Other branch");
88 if (LOG.isDebugEnabled()) {
89 LOG.debug("no " + outValue + " or Other branch found");