</organization>
<modules>
+ <module>provider-base</module>
<module>model</module>
<module>common</module>
<module>provider</module>
--- /dev/null
+<?xml version="1.0"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>binding-parent</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath />
+ </parent>
+
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-provider-base</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>dblib-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-common</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- Testing Dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
-import org.onap.ccsdk.sli.core.sli.MetricLogger;
import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public abstract class SvcLogicNodeExecutor {
+public abstract class AbstractSvcLogicNodeExecutor {
+ protected SvcLogicResolver resolver;
+ public abstract SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException;
- public abstract SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException;
-
- private static final Logger LOG = LoggerFactory.getLogger(SvcLogicNodeExecutor.class);
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractSvcLogicNodeExecutor.class);
protected String evaluateNodeTest(SvcLogicNode node, SvcLogicContext ctx)
throws SvcLogicException {
}
+ public void setResolver(SvcLogicResolver resolver) {
+ this.resolver = resolver;
+ }
-
- protected SvcLogicAdaptor getAdaptor(String adaptorName) {
- return SvcLogicAdaptorFactory.getInstance(adaptorName);
+ protected SvcLogicAdaptor getAdaptor(String adaptorName) {
+ return resolver.getSvcLogicAdaptor(adaptorName);
}
- protected SvcLogicResource getSvcLogicResource(String plugin) {
-
- return((SvcLogicResource) SvcLogicClassResolver.resolve(plugin));
+ protected SvcLogicResource getSvcLogicResource(String resourceName) {
+ return resolver.getSvcLogicResource(resourceName);
}
- protected SvcLogicRecorder getSvcLogicRecorder(String plugin) {
- return((SvcLogicRecorder) SvcLogicClassResolver.resolve(plugin));
+ protected SvcLogicRecorder getSvcLogicRecorder(String recorderName) {
+ return resolver.getSvcLogicRecorder(recorderName);
}
protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName){
- return((SvcLogicJavaPlugin) SvcLogicClassResolver.resolve(pluginName));
-
+ return resolver.getSvcLogicJavaPlugin(pluginName);
}
protected SvcLogicNode getNextNode(SvcLogicNode node, String outValue) {
- MetricLogger.resetContext();
SvcLogicNode nextNode = node.getOutcomeValue(outValue);
if (nextNode != null) {
if (LOG.isDebugEnabled()) {
}
return (nextNode);
}
+
}
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class BlockNodeExecutor extends SvcLogicNodeExecutor {
+public class BlockNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory
.getLogger(BlockNodeExecutor.class);
@Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx)
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx)
throws SvcLogicException {
SvcLogicExpression atomicExpr = node.getAttribute("atomic");
}
+
}
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import org.onap.ccsdk.sli.core.sli.BreakNodeException;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class BreakNodeExecutor extends SvcLogicNodeExecutor {
+public class BreakNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory.getLogger(BreakNodeExecutor.class);
@Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
String message = "BreakNodeExecutor encountered break with nodeId " + node.getNodeId();
LOG.debug(message);
throw new BreakNodeException(message);
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class CallNodeExecutor extends SvcLogicNodeExecutor {
+public class CallNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory
.getLogger(CallNodeExecutor.class);
@Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx)
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx)
throws SvcLogicException {
String outValue = "not-found";
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import java.util.HashMap;
import java.util.Iterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ConfigureNodeExecutor extends SvcLogicNodeExecutor {
+public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory
.getLogger(ConfigureNodeExecutor.class);
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node,
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node,
SvcLogicContext ctx) throws SvcLogicException {
String adaptorName = SvcLogicExpressionResolver.evaluate(
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class DeleteNodeExecutor extends SvcLogicNodeExecutor {
+public class DeleteNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory.getLogger(DeleteNodeExecutor.class);
private static final String FAILURE="failure";
@Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx)
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx)
throws SvcLogicException {
String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ExecuteNodeExecutor extends SvcLogicNodeExecutor {
+public class ExecuteNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory
.getLogger(ExecuteNodeExecutor.class);
private static final String pluginErrorMessage = "Could not execute plugin. SvcLogic status will be set to failure.";
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node,
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node,
SvcLogicContext ctx) throws SvcLogicException {
String pluginName = SvcLogicExpressionResolver.evaluate(
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ExistsNodeExecutor extends SvcLogicNodeExecutor {
+public class ExistsNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory.getLogger(ExistsNodeExecutor.class);
@Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx)
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx)
throws SvcLogicException {
String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import org.onap.ccsdk.sli.core.sli.ExitNodeException;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ExitNodeExecutor extends SvcLogicNodeExecutor {
+public class ExitNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory.getLogger(ExitNodeExecutor.class);
@Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
String message = "ExitNodeExecutor encountered exit with nodeId " + node.getNodeId();
LOG.debug(message);
throw new ExitNodeException(message);
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import org.onap.ccsdk.sli.core.sli.BreakNodeException;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ForNodeExecutor extends SvcLogicNodeExecutor {
+public class ForNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory
.getLogger(ForNodeExecutor.class);
@Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node,
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node,
SvcLogicContext ctx) throws SvcLogicException {
SvcLogicExpression atomicExpr = node.getAttribute("atomic");
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class GetResourceNodeExecutor extends SvcLogicNodeExecutor {
+public class GetResourceNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory.getLogger(GetResourceNodeExecutor.class);
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx)
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx)
throws SvcLogicException {
String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class IsAvailableNodeExecutor extends SvcLogicNodeExecutor {
+public class IsAvailableNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory.getLogger(IsAvailableNodeExecutor.class);
@Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx)
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx)
throws SvcLogicException {
String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class NotifyNodeExecutor extends SvcLogicNodeExecutor {
+public class NotifyNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory.getLogger(NotifyNodeExecutor.class);
@Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx)
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx)
throws SvcLogicException {
String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import java.util.HashMap;
import java.util.Iterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class RecordNodeExecutor extends SvcLogicNodeExecutor {
+public class RecordNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory.getLogger(RecordNodeExecutor.class);
@Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx)
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx)
throws SvcLogicException {
String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ReleaseNodeExecutor extends SvcLogicNodeExecutor {
+public class ReleaseNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory.getLogger(ReleaseNodeExecutor.class);
@Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx)
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx)
throws SvcLogicException {
String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ReserveNodeExecutor extends SvcLogicNodeExecutor {
+public class ReserveNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory.getLogger(ReserveNodeExecutor.class);
@Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx)
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx)
throws SvcLogicException {
String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import java.util.Iterator;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ReturnNodeExecutor extends SvcLogicNodeExecutor {
+public class ReturnNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory
.getLogger(ReturnNodeExecutor.class);
@Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node,
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node,
SvcLogicContext ctx) throws SvcLogicException {
String status = SvcLogicExpressionResolver.evaluate(
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import java.util.HashMap;
import java.util.Iterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class SaveNodeExecutor extends SvcLogicNodeExecutor {
+public class SaveNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory.getLogger(SaveNodeExecutor.class);
@Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx)
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx)
throws SvcLogicException {
String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import java.util.HashMap;
import java.util.Iterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class SetNodeExecutor extends SvcLogicNodeExecutor {
+public class SetNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory.getLogger(SetNodeExecutor.class);
protected final String arrayPattern = "\\[\\d*\\]";
@Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx)
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx)
throws SvcLogicException {
execute(node,ctx);
return null;
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import java.util.List;
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import java.util.Properties;
--- /dev/null
+package org.onap.ccsdk.sli.core.sli.provider.base;
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor;
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
+import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder;
+import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
+
+public interface SvcLogicResolver {
+
+ abstract SvcLogicResource getSvcLogicResource(String resourceName);
+
+ abstract SvcLogicRecorder getSvcLogicRecorder(String recorderName);
+
+ abstract SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName);
+
+ abstract SvcLogicAdaptor getSvcLogicAdaptor(String adaptorName);
+}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.core.sli.provider.base;
+
+import java.util.Properties;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
+import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
+import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
+
+public interface SvcLogicServiceBase {
+
+
+ /**
+ * Check for existence of a directed graph
+ * @param module - module name
+ * @param rpc - rpc name
+ * @param version - version. If null, looks for active version
+ * @param mode - mode (sync/async)
+ * @return true if directed graph found, false otherwise
+ * @throws SvcLogicException
+ */
+ boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException;
+
+ /**
+ * Execute a directed graph
+ *
+ * @param module - module name
+ * @param rpc - rpc name
+ * @param version - version. If null, use active version
+ * @param mode - mode (sync/async)
+ * @param parms - parameters, used to set SvcLogicContext attributes
+ * @return final values of attributes from SvcLogicContext, as Properties
+ * @throws SvcLogicException
+ *
+ *
+ */
+ Properties execute(String module, String rpc, String version, String mode, Properties parms) throws SvcLogicException;
+
+ SvcLogicStore getStore() throws SvcLogicException;
+
+ SvcLogicContext execute(SvcLogicGraph calledGraph, SvcLogicContext ctx) throws SvcLogicException;
+
+ SvcLogicNode executeNode(SvcLogicNode nextNode, SvcLogicContext ctx) throws SvcLogicException;
+
+}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.core.sli.provider.base;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.onap.ccsdk.sli.core.sli.ExitNodeException;
+import org.onap.ccsdk.sli.core.sli.MetricLogger;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
+import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
+import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+
+public class SvcLogicServiceImplBase implements SvcLogicServiceBase {
+ protected SvcLogicResolver resolver;
+ protected static final Map<String, AbstractSvcLogicNodeExecutor> BUILTIN_NODES = new HashMap<String, AbstractSvcLogicNodeExecutor>() {
+ {
+ put("block", new BlockNodeExecutor());
+ put("call", new CallNodeExecutor());
+ put("configure", new ConfigureNodeExecutor());
+ put("delete", new DeleteNodeExecutor());
+ put("execute", new ExecuteNodeExecutor());
+ put("exists", new ExistsNodeExecutor());
+ put("for", new ForNodeExecutor());
+ put("get-resource", new GetResourceNodeExecutor());
+ put("is-available", new IsAvailableNodeExecutor());
+ put("notify", new NotifyNodeExecutor());
+ put("record", new RecordNodeExecutor());
+ put("release", new ReleaseNodeExecutor());
+ put("reserve", new ReserveNodeExecutor());
+ put("return", new ReturnNodeExecutor());
+ put("save", new SaveNodeExecutor());
+ put("set", new SetNodeExecutor());
+ put("switch", new SwitchNodeExecutor());
+ put("update", new UpdateNodeExecutor());
+ put("break", new BreakNodeExecutor());
+ put("while", new WhileNodeExecutor());
+ put("exit", new ExitNodeExecutor());
+ }
+ };
+
+ private static final Logger LOG = LoggerFactory.getLogger(SvcLogicServiceImplBase.class);
+ protected HashMap<String, AbstractSvcLogicNodeExecutor> nodeExecutors = null;
+ protected Properties properties;
+ protected SvcLogicStore store;
+ protected static final String CURRENT_GRAPH="currentGraph";
+
+ public SvcLogicServiceImplBase(SvcLogicStore store) {
+ this.store = store;
+ }
+
+ protected void registerExecutors() {
+
+ LOG.info("Entered register executors");
+ for (String nodeType : BUILTIN_NODES.keySet()) {
+ LOG.info("SLI - registering node executor for node type " + nodeType);
+ registerExecutor(nodeType, BUILTIN_NODES.get(nodeType));
+ }
+ LOG.info("Done registerExecutors");
+ }
+
+ public void registerExecutor(String nodeName, AbstractSvcLogicNodeExecutor executor) {
+ if (nodeExecutors == null) {
+ nodeExecutors = new HashMap<>();
+ }
+ LOG.info("SLI - registering executor for node type {}", nodeName);
+ executor.setResolver(resolver);
+ nodeExecutors.put(nodeName, executor);
+ }
+
+ public void unregisterExecutor(String nodeName) {
+ LOG.info("SLI - unregistering executor for node type {}", nodeName);
+ nodeExecutors.remove(nodeName);
+ }
+
+ public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) throws SvcLogicException {
+ if (nodeExecutors == null) {
+ registerExecutors();
+ }
+
+ // Set service name in MDC to reference current working directed graph
+ MDC.put(MetricLogger.SERVICE_NAME, graph.getModule() + ":" + graph.getRpc() + "/v" + graph.getVersion());
+
+ MDC.put(CURRENT_GRAPH, graph.toString());
+
+ SvcLogicNode curNode = graph.getRootNode();
+ LOG.info("About to execute graph {}", graph.toString());
+ try {
+ while (curNode != null) {
+ resetContext();
+ SvcLogicNode nextNode = executeNode(curNode, ctx);
+ curNode = nextNode;
+ }
+ } catch (ExitNodeException e) {
+ LOG.debug("SvcLogicServiceImpl caught ExitNodeException");
+ }
+ MDC.remove("nodeId");
+ MDC.remove(CURRENT_GRAPH);
+
+ return (ctx);
+ }
+
+ protected void resetContext() {
+
+ }
+
+ public SvcLogicNode executeNode(SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
+ if (node == null) {
+ return (null);
+ }
+
+ LOG.info("About to execute node # {} ({})", node.getNodeId(), node.getNodeType());
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Executing node " + node.getNodeId() + " of " + node.getGraph().getRpc());
+ }
+
+ AbstractSvcLogicNodeExecutor executor = nodeExecutors.get(node.getNodeType());
+
+ if (executor != null) {
+ LOG.debug("Executing node executor for node type {} - {}", node.getNodeType(),
+ executor.getClass().getName());
+
+ MDC.put("nodeId", node.getNodeId() + " (" + node.getNodeType() + ")");
+ return (executor.execute(this, node, ctx));
+ } else {
+ throw new SvcLogicException("Attempted to execute a node of type " + node.getNodeType() + ", but no executor was registered for this type");
+ }
+ }
+
+ @Override
+ public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException {
+ return (store.hasGraph(module, rpc, version, mode));
+ }
+
+ @Override
+ public Properties execute(String module, String rpc, String version, String mode, Properties props)
+ throws SvcLogicException {
+ LOG.info("Fetching service logic from data store");
+ SvcLogicGraph graph = store.fetch(module, rpc, version, mode);
+
+ if (graph == null) {
+ Properties retProps = new Properties();
+ retProps.setProperty("error-code", "401");
+ retProps.setProperty("error-message",
+ "No service logic found for [" + module + "," + rpc + "," + version + "," + mode + "]");
+ return (retProps);
+ }
+
+ SvcLogicContext ctx = new SvcLogicContext(props);
+ ctx.setAttribute(CURRENT_GRAPH, graph.toString());
+ ctx.setAttribute("X-ECOMP-RequestID", MDC.get("X-ECOMP-RequestID"));
+ execute(graph, ctx);
+ return (ctx.toProperties());
+ }
+
+ @Override
+ public SvcLogicStore getStore() throws SvcLogicException {
+ return this.store;
+ }
+
+}
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class SwitchNodeExecutor extends SvcLogicNodeExecutor {
+public class SwitchNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory
.getLogger(SwitchNodeExecutor.class);
@Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node,
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node,
SvcLogicContext ctx) throws SvcLogicException {
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import java.util.HashMap;
import java.util.Iterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class UpdateNodeExecutor extends SvcLogicNodeExecutor {
+public class UpdateNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory.getLogger(UpdateNodeExecutor.class);
@Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx)
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx)
throws SvcLogicException {
String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import org.onap.ccsdk.sli.core.sli.BreakNodeException;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class WhileNodeExecutor extends SvcLogicNodeExecutor {
+public class WhileNodeExecutor extends AbstractSvcLogicNodeExecutor {
private static final Logger LOG = LoggerFactory.getLogger(WhileNodeExecutor.class);
@Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
+ public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
String testResult = evaluateNodeTest(node, ctx);
SvcLogicExpression silentFailureExpr = node.getAttribute("do");
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import java.util.Map;
/**
*
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import java.util.Map;
import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor;
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import java.util.Map;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
/**
*
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import java.util.Map;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import java.util.Map.Entry;
+import java.util.Properties;
import org.onap.ccsdk.sli.core.sli.DuplicateValueException;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.onap.ccsdk.sli.core.sli.provider.ExecuteNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.SvcLogicServiceImpl;
+import org.onap.ccsdk.sli.core.sli.provider.base.ExecuteNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase;
import junit.framework.TestCase;
MockExecuteNodeExecutor execute = new MockExecuteNodeExecutor();
SvcLogicNode node = new SvcLogicNode(0, "", "", new SvcLogicGraph());
node.setAttribute("method", "selectLunch");
- SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProviderImpl();
- execute.execute(new SvcLogicServiceImpl(resourceProvider), new SvcLogicNode(0, "", "", new SvcLogicGraph()), new SvcLogicContext());
+ SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProvider() {
+
+ public Properties getProperties() {
+ return new Properties();
+ };
+ };
+
+
+ execute.execute(new SvcLogicServiceImplBase(null), new SvcLogicNode(0, "", "", new SvcLogicGraph()), new SvcLogicContext());
}
}
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import java.util.Map;
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import java.lang.reflect.Method;
import java.util.HashMap;
import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.onap.ccsdk.sli.core.sli.provider.ExecuteNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.SvcLogicExpressionResolver;
+import org.onap.ccsdk.sli.core.sli.provider.base.ExecuteNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicExpressionResolver;
import junit.framework.TestCase;
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
import org.onap.ccsdk.sli.core.sli.SvcLogicParser;
+import org.onap.ccsdk.sli.core.sli.provider.base.SetNodeExecutor;
public class SetNodeExecutorTest {
@Test
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import java.io.BufferedReader;
import java.io.InputStream;
import org.onap.ccsdk.sli.core.sli.SvcLogicExpressionFactory;
import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.onap.ccsdk.sli.core.sli.provider.SvcLogicExpressionResolver;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicExpressionResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli.provider;
+package org.onap.ccsdk.sli.core.sli.provider.base;
import java.util.Map;
--- /dev/null
+###
+# ============LICENSE_START=======================================================
+# ONAP : CCSDK
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+org.slf4j.simpleLogger.defaultLogLevel=info
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-provider-base</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
import java.util.HashMap;
import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
return adaptorMap.get(name);
} else {
- SvcLogicAdaptor adaptor = (SvcLogicAdaptor) SvcLogicClassResolver.resolve(name);
+ SvcLogicAdaptor adaptor = (SvcLogicAdaptor) SvcLogicClassResolver.getInstance().resolve(name);
if (adaptor != null) {
registerAdaptor(adaptor);
package org.onap.ccsdk.sli.core.sli.provider;
+import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor;
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
+import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder;
+import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicResolver;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class SvcLogicClassResolver {
- private static final Logger LOG = LoggerFactory.getLogger(SvcLogicClassResolver.class);
+public class SvcLogicClassResolver implements SvcLogicResolver {
+ private static final Logger LOG = LoggerFactory.getLogger(SvcLogicClassResolver.class);
+ private static SvcLogicClassResolver instance = new SvcLogicClassResolver();
- public static Object resolve(String className) {
+ private SvcLogicClassResolver() {
+ }
- Bundle bundle = FrameworkUtil.getBundle(SvcLogicClassResolver.class);
+ public static SvcLogicClassResolver getInstance() {
+ return instance;
+ }
- if (bundle == null) {
- // Running outside OSGi container (e.g. jUnit). Use Reflection
- // to resolve class
- try {
- return(Class.forName(className).newInstance());
- } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
+ public Object resolve(String className) {
- LOG.error("Could not resolve class "+className, e);
- return null;
- }
+ Bundle bundle = FrameworkUtil.getBundle(SvcLogicClassResolver.class);
- } else {
- BundleContext bctx = bundle.getBundleContext();
- ServiceReference sref = bctx.getServiceReference(className);
- if (sref != null) {
- return bctx.getService(sref);
- } else {
+ if (bundle == null) {
+ // Running outside OSGi container (e.g. jUnit). Use Reflection
+ // to resolve class
+ try {
+ return (Class.forName(className).newInstance());
+ } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
- LOG.warn("Could not find service reference object for class " + className);
- return null;
- }
- }
- }
+ LOG.error("Could not resolve class " + className, e);
+ return null;
+ }
+
+ } else {
+ BundleContext bctx = bundle.getBundleContext();
+ ServiceReference sref = bctx.getServiceReference(className);
+ if (sref != null) {
+ return bctx.getService(sref);
+ } else {
+
+ LOG.warn("Could not find service reference object for class " + className);
+ return null;
+ }
+ }
+ }
+
+ @Override
+ public SvcLogicResource getSvcLogicResource(String resourceName) {
+ return (SvcLogicResource) resolve(resourceName);
+ }
+
+ @Override
+ public SvcLogicRecorder getSvcLogicRecorder(String recorderName) {
+ return (SvcLogicRecorder) resolve(recorderName);
+ }
+
+ @Override
+ public SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName) {
+ return (SvcLogicJavaPlugin) resolve(pluginName);
+ }
+
+ @Override
+ public SvcLogicAdaptor getSvcLogicAdaptor(String adaptorName) {
+ return SvcLogicAdaptorFactory.getInstance(adaptorName);
+ }
}
import org.onap.ccsdk.sli.core.dblib.DblibConfigurationException;
import org.onap.ccsdk.sli.core.sli.ConfigurationException;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider;
import org.onap.ccsdk.sli.core.utils.JREFileResolver;
import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver;
import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver;
package org.onap.ccsdk.sli.core.sli.provider;
import java.util.Properties;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-public interface SvcLogicService {
+public interface SvcLogicService extends SvcLogicServiceBase {
String NAME = "org.onap.ccsdk.sli.core.sli.provider.SvcLogicService";
- // public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) throws SvcLogicException;
- /**
- * Check for existence of a directed graph
- * @param module - module name
- * @param rpc - rpc name
- * @param version - version. If null, looks for active version
- * @param mode - mode (sync/async)
- * @return true if directed graph found, false otherwise
- * @throws SvcLogicException
- */
- boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException;
-
- /**
- * Execute a directed graph
- *
- * @param module - module name
- * @param rpc - rpc name
- * @param version - version. If null, use active version
- * @param mode - mode (sync/async)
- * @param parms - parameters, used to set SvcLogicContext attributes
- * @return final values of attributes from SvcLogicContext, as Properties
- * @throws SvcLogicException
- *
- *
- * @deprecated use execute(String module, String rpc, String version, String mode, DOMDataBroker dataBroker) instead
- */
@Deprecated
Properties execute(String module, String rpc, String version, String mode, Properties parms) throws SvcLogicException;
*/
Properties execute(String module, String rpc, String version, String mode, Properties parms, DOMDataBroker domDataBroker) throws SvcLogicException;
- SvcLogicStore getStore() throws SvcLogicException;
-
- SvcLogicContext execute(SvcLogicGraph calledGraph, SvcLogicContext ctx) throws SvcLogicException;
-
- SvcLogicNode executeNode(SvcLogicNode nextNode, SvcLogicContext ctx) throws SvcLogicException;
}
package org.onap.ccsdk.sli.core.sli.provider;
-import java.util.HashMap;
-import java.util.Map;
import java.util.Properties;
+
import org.onap.ccsdk.sli.core.dblib.DbLibService;
import org.onap.ccsdk.sli.core.sli.ConfigurationException;
-import org.onap.ccsdk.sli.core.sli.ExitNodeException;
import org.onap.ccsdk.sli.core.sli.MetricLogger;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicDblibStore;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory;
+import org.onap.ccsdk.sli.core.sli.provider.base.AbstractSvcLogicNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
-public class SvcLogicServiceImpl implements SvcLogicService {
-
- private static final Map<String, SvcLogicNodeExecutor> BUILTIN_NODES = new HashMap<String, SvcLogicNodeExecutor>() {
- {
- put("block", new BlockNodeExecutor());
- put("call", new CallNodeExecutor());
- put("configure", new ConfigureNodeExecutor());
- put("delete", new DeleteNodeExecutor());
- put("execute", new ExecuteNodeExecutor());
- put("exists", new ExistsNodeExecutor());
- put("for", new ForNodeExecutor());
- put("get-resource", new GetResourceNodeExecutor());
- put("is-available", new IsAvailableNodeExecutor());
- put("notify", new NotifyNodeExecutor());
- put("record", new RecordNodeExecutor());
- put("release", new ReleaseNodeExecutor());
- put("reserve", new ReserveNodeExecutor());
- put("return", new ReturnNodeExecutor());
- put("save", new SaveNodeExecutor());
- put("set", new SetNodeExecutor());
- put("switch", new SwitchNodeExecutor());
- put("update", new UpdateNodeExecutor());
- put("break", new BreakNodeExecutor());
- put("while", new WhileNodeExecutor());
- put("exit", new ExitNodeExecutor());
- }
- };
+public class SvcLogicServiceImpl extends SvcLogicServiceImplBase implements SvcLogicService {
private static final Logger LOG = LoggerFactory.getLogger(SvcLogicServiceImpl.class);
- protected HashMap<String, SvcLogicNodeExecutor> nodeExecutors = null;
protected BundleContext bctx = null;
- protected Properties properties;
- protected SvcLogicStore store;
- private static final String CURRENT_GRAPH="currentGraph";
public SvcLogicServiceImpl(SvcLogicPropertiesProvider resourceProvider) throws SvcLogicException {
+ super(null);
+ this.resolver = SvcLogicClassResolver.getInstance();
properties = resourceProvider.getProperties();
- getStore();
+ this.store = getStore();
}
public SvcLogicServiceImpl(SvcLogicPropertiesProvider resourceProvider, DbLibService dbSvc)
throws SvcLogicException {
+ super(null);
+ this.resolver = SvcLogicClassResolver.getInstance();
properties = resourceProvider.getProperties();
- store = new SvcLogicDblibStore(dbSvc);
- }
-
-
- protected void registerExecutors() {
-
- LOG.info("Entered register executors");
- for (String nodeType : BUILTIN_NODES.keySet()) {
- LOG.info("SLI - registering node executor for node type " + nodeType);
- registerExecutor(nodeType, BUILTIN_NODES.get(nodeType));
- }
- LOG.info("Done registerExecutors");
+ this.store = new SvcLogicDblibStore(dbSvc);
}
public void registerExecutor(ServiceReference sr) {
String nodeName = (String) sr.getProperty("nodeType");
if (nodeName != null) {
-
- SvcLogicNodeExecutor executor;
-
+ AbstractSvcLogicNodeExecutor executor;
try {
- executor = (SvcLogicNodeExecutor) bctx.getService(sr);
+ executor = (AbstractSvcLogicNodeExecutor) bctx.getService(sr);
} catch (Exception e) {
LOG.error("Cannot get service executor for {}", nodeName, e);
return;
}
}
- public void registerExecutor(String nodeName, SvcLogicNodeExecutor executor) {
- if (nodeExecutors == null) {
- nodeExecutors = new HashMap<>();
- }
- LOG.info("SLI - registering executor for node type {}", nodeName);
- nodeExecutors.put(nodeName, executor);
- }
-
public void unregisterExecutor(ServiceReference sr) {
String nodeName = (String) sr.getProperty("nodeType");
}
}
- public void unregisterExecutor(String nodeName) {
- LOG.info("SLI - unregistering executor for node type {}", nodeName);
- nodeExecutors.remove(nodeName);
- }
-
- public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) throws SvcLogicException {
- if (nodeExecutors == null) {
- registerExecutors();
- }
-
- // Set service name in MDC to reference current working directed graph
- MDC.put(MetricLogger.SERVICE_NAME, graph.getModule() + ":" + graph.getRpc() + "/v" + graph.getVersion());
-
- MDC.put(CURRENT_GRAPH, graph.toString());
-
- SvcLogicNode curNode = graph.getRootNode();
- LOG.info("About to execute graph {}", graph.toString());
- try {
- while (curNode != null) {
-
- SvcLogicNode nextNode = executeNode(curNode, ctx);
- curNode = nextNode;
- }
- } catch (ExitNodeException e) {
- LOG.debug("SvcLogicServiceImpl caught ExitNodeException");
- }
- MDC.remove("nodeId");
- MDC.remove(CURRENT_GRAPH);
-
- return (ctx);
- }
-
- public SvcLogicNode executeNode(SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
- if (node == null) {
- return (null);
- }
-
- LOG.info("About to execute node # {} ({})", node.getNodeId(), node.getNodeType());
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Executing node " + node.getNodeId() + " of " + node.getGraph().getRpc());
- }
-
- SvcLogicNodeExecutor executor = nodeExecutors.get(node.getNodeType());
-
- if (executor != null) {
- LOG.debug("Executing node executor for node type {} - {}", node.getNodeType(),
- executor.getClass().getName());
-
- MDC.put("nodeId", node.getNodeId() + " (" + node.getNodeType() + ")");
- return (executor.execute(this, node, ctx));
- } else {
- throw new SvcLogicException("Attempted to execute a node of type " + node.getNodeType() + ", but no executor was registered for this type");
- }
- }
-
- @Override
- public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException {
- return (store.hasGraph(module, rpc, version, mode));
- }
-
@Override
public Properties execute(String module, String rpc, String version, String mode, Properties props)
throws SvcLogicException {
ctx.setAttribute(CURRENT_GRAPH, graph.toString());
ctx.setAttribute("X-ECOMP-RequestID", MDC.get("X-ECOMP-RequestID"));
ctx.setDomDataBroker(domDataBroker);
-
execute(graph, ctx);
-
return (ctx.toProperties());
}
+
+ @Override
+ protected void resetContext() {
+ MetricLogger.resetContext();
+ }
+ @Override
public SvcLogicStore getStore() throws SvcLogicException {
// Create and initialize SvcLogicStore object - used to access
// saved service logic.
return store;
}
+
}
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
-
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Map;
import java.util.Properties;
+
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
import org.onap.ccsdk.sli.core.sli.SvcLogicParser;
import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceRegistration;
+import org.onap.ccsdk.sli.core.sli.provider.base.BlockNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.BreakNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.CallNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.ConfigureNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.DeleteNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.ExecuteNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.ExistsNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.ForNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.GetResourceNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.IsAvailableNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.NotifyNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.RecordNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.ReleaseNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.ReserveNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.ReturnNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.SaveNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.SetNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.AbstractSvcLogicNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider;
+import org.onap.ccsdk.sli.core.sli.provider.base.SwitchNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.UpdateNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.WhileNodeExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ITCaseSvcLogicGraphExecutor {
private static final Logger LOG = LoggerFactory.getLogger(SvcLogicGraph.class);
- private static final Map<String, SvcLogicNodeExecutor> BUILTIN_NODES = new HashMap<String, SvcLogicNodeExecutor>() {
+ private static final Map<String, AbstractSvcLogicNodeExecutor> BUILTIN_NODES = new HashMap<String, AbstractSvcLogicNodeExecutor>() {
{
put("block", new BlockNodeExecutor());
put("break", new BreakNodeExecutor());
+++ /dev/null
-#######################################
<artifactId>sli-provider</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-provider-base</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-core-api</artifactId>
import org.onap.ccsdk.sli.core.sli.SvcLogicParser;
import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory;
-import org.onap.ccsdk.sli.core.sli.provider.BlockNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.CallNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.ConfigureNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.DeleteNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.ExecuteNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.ExistsNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.ForNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.GetResourceNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.IsAvailableNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.NotifyNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.RecordNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.ReleaseNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.ReserveNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.ReturnNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.SaveNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.SetNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.SvcLogicNodeExecutor;
import org.onap.ccsdk.sli.core.sli.provider.SvcLogicPropertiesProviderImpl;
import org.onap.ccsdk.sli.core.sli.provider.SvcLogicServiceImpl;
-import org.onap.ccsdk.sli.core.sli.provider.SwitchNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.UpdateNodeExecutor;
-import org.onap.ccsdk.sli.core.sli.provider.WhileNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.AbstractSvcLogicNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.BlockNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.CallNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.ConfigureNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.DeleteNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.ExecuteNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.ExistsNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.ForNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.GetResourceNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.IsAvailableNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.NotifyNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.RecordNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.ReleaseNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.ReserveNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.ReturnNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.SaveNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.SetNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.SwitchNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.UpdateNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.WhileNodeExecutor;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
private static final String HEALTHCHECK_DG = "sli_healthcheck.xml";
- private static final Map<String, SvcLogicNodeExecutor> BUILTIN_NODES = new HashMap<String, SvcLogicNodeExecutor>() {
+ private static final Map<String, AbstractSvcLogicNodeExecutor> BUILTIN_NODES = new HashMap<String, AbstractSvcLogicNodeExecutor>() {
{
put("block", new BlockNodeExecutor());
put("call", new CallNodeExecutor());