2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 ONAP
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.ccsdk.sli.core.sli.provider;
23 import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor;
24 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
25 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
26 import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
27 import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
28 import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder;
29 import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
30 import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
31 import org.osgi.framework.BundleContext;
32 import org.osgi.framework.FrameworkUtil;
33 import org.osgi.framework.ServiceReference;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
37 public abstract class SvcLogicNodeExecutor {
39 public abstract SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException;
41 private static final Logger LOG = LoggerFactory.getLogger(SvcLogicNodeExecutor.class);
43 protected String evaluateNodeTest(SvcLogicNode node, SvcLogicContext ctx)
44 throws SvcLogicException {
49 return (SvcLogicExpressionResolver.evaluate(node.getAttribute("test"),
54 protected SvcLogicStore getStore() throws SvcLogicException {
55 return SvcLogicActivator.getStore();
58 protected SvcLogicAdaptor getAdaptor(String adaptorName) {
59 return SvcLogicAdaptorFactory.getInstance(adaptorName);
62 protected SvcLogicResource getSvcLogicResource(String plugin) {
63 BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
66 ServiceReference sref = bctx.getServiceReference(plugin);
68 SvcLogicResource resourcePlugin = (SvcLogicResource) bctx
70 return resourcePlugin;
73 LOG.warn("Could not find service reference object for plugin " + plugin);
78 protected SvcLogicRecorder getSvcLogicRecorder(String plugin) {
79 BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
82 ServiceReference sref = bctx.getServiceReference(plugin);
84 SvcLogicRecorder resourcePlugin = (SvcLogicRecorder) bctx
86 return resourcePlugin;
93 protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName){
94 BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
97 ServiceReference sref = bctx.getServiceReference(pluginName);
100 LOG.warn("Could not find service reference object for plugin " + pluginName);
103 SvcLogicJavaPlugin plugin = (SvcLogicJavaPlugin) bctx