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.openecomp.sdnc.sli.provider;
24 import org.openecomp.sdnc.sli.SvcLogicAdaptor;
25 import org.openecomp.sdnc.sli.SvcLogicContext;
26 import org.openecomp.sdnc.sli.SvcLogicException;
27 import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
28 import org.openecomp.sdnc.sli.SvcLogicNode;
29 import org.openecomp.sdnc.sli.SvcLogicRecorder;
30 import org.openecomp.sdnc.sli.SvcLogicResource;
31 import org.openecomp.sdnc.sli.SvcLogicStore;
32 import org.osgi.framework.BundleContext;
33 import org.osgi.framework.FrameworkUtil;
34 import org.osgi.framework.ServiceReference;
35 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory;
38 public abstract class SvcLogicNodeExecutor {
40 public abstract SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException;
42 private static final Logger LOG = LoggerFactory.getLogger(SvcLogicNodeExecutor.class);
44 protected String evaluateNodeTest(SvcLogicNode node, SvcLogicContext ctx)
45 throws SvcLogicException {
50 return (SvcLogicExpressionResolver.evaluate(node.getAttribute("test"),
55 protected SvcLogicStore getStore() throws SvcLogicException {
56 return SvcLogicActivator.getStore();
59 protected SvcLogicAdaptor getAdaptor(String adaptorName) {
60 return SvcLogicAdaptorFactory.getInstance(adaptorName);
63 protected SvcLogicResource getSvcLogicResource(String plugin) {
64 BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
67 ServiceReference sref = bctx.getServiceReference(plugin);
69 SvcLogicResource resourcePlugin = (SvcLogicResource) bctx
71 return resourcePlugin;
74 LOG.warn("Could not find service reference object for plugin " + plugin);
79 protected SvcLogicRecorder getSvcLogicRecorder(String plugin) {
80 BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
83 ServiceReference sref = bctx.getServiceReference(plugin);
85 SvcLogicRecorder resourcePlugin = (SvcLogicRecorder) bctx
87 return resourcePlugin;
94 protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName){
95 BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
98 ServiceReference sref = bctx.getServiceReference(pluginName);
101 LOG.warn("Could not find service reference object for plugin " + pluginName);
104 SvcLogicJavaPlugin plugin = (SvcLogicJavaPlugin) bctx