Refactor sliapi springboot
[ccsdk/sli/core.git] / sliapi / springboot / src / main / java / org / onap / ccsdk / sli / core / sliapi / springboot / core / SvcLogicFactory.java
diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java
deleted file mode 100644 (file)
index 0c8480e..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP - CCSDK\r
- * ================================================================================\r
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.onap.ccsdk.sli.core.sliapi.springboot.core;\r
-\r
-import java.io.FileInputStream;\r
-import java.io.IOException;\r
-import java.util.List;\r
-import java.util.Properties;\r
-import org.onap.ccsdk.sli.core.sli.ConfigurationException;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicLoader;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicStore;\r
-import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory;\r
-import org.onap.ccsdk.sli.core.sli.provider.base.HashMapResolver;\r
-import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider;\r
-import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicResolver;\r
-import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase;\r
-import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase;\r
-import org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder;\r
-import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils;\r
-import org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils;\r
-import org.onap.ccsdk.sli.plugins.prop.PropertiesNode;\r
-import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.context.annotation.Bean;\r
-import org.springframework.context.annotation.Configuration;\r
-\r
-@Configuration\r
-public class SvcLogicFactory {\r
-  private static final Logger log = LoggerFactory.getLogger(SvcLogicFactory.class);\r
-\r
-  @Autowired\r
-  List<SvcLogicRecorder> recorders;\r
-\r
-  @Autowired\r
-  List<SvcLogicJavaPlugin> plugins;\r
-\r
-  @Bean\r
-  public SvcLogicStore getStore() throws Exception {\r
-    SvcLogicPropertiesProvider propProvider = new SvcLogicPropertiesProvider() {\r
-\r
-      @Override\r
-      public Properties getProperties() {\r
-        Properties props = new Properties();\r
-\r
-\r
-        String propPath = System.getProperty("serviceLogicProperties", "");\r
-\r
-        if ("".equals(propPath)) {\r
-          propPath = System.getenv("SVCLOGIC_PROPERTIES");\r
-        }\r
-\r
-\r
-        if ((propPath == null) || propPath.length() == 0) {\r
-          propPath = "src/main/resources/svclogic.properties";\r
-        }\r
-        System.out.println(propPath);\r
-        try (FileInputStream fileInputStream = new FileInputStream(propPath)) {\r
-          props = new Properties();\r
-          props.load(fileInputStream);\r
-        } catch (final IOException e) {\r
-          log.error("Failed to load properties for file: {}", propPath,\r
-              new ConfigurationException("Failed to load properties for file: " + propPath, e));\r
-        }\r
-        return props;\r
-      }\r
-    };\r
-    SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propProvider.getProperties());\r
-    return store;\r
-  }\r
-\r
-  @Bean\r
-  public SvcLogicLoader createLoader() throws Exception {\r
-    String serviceLogicDirectory = System.getProperty("serviceLogicDirectory");\r
-    if (serviceLogicDirectory == null) {\r
-      serviceLogicDirectory = "src/main/resources";\r
-    }\r
-\r
-    System.out.println("serviceLogicDirectory is " + serviceLogicDirectory);\r
-    SvcLogicLoader loader = new SvcLogicLoader(serviceLogicDirectory, getStore());\r
-\r
-    try {\r
-      loader.loadAndActivate();\r
-    } catch (IOException e) {\r
-      log.error("Cannot load directed graphs", e);\r
-    }\r
-    return loader;\r
-  }\r
-\r
-  @Bean\r
-  public SvcLogicServiceBase createService() throws Exception {\r
-    HashMapResolver resolver = new HashMapResolver();\r
-    for (SvcLogicRecorder recorder : recorders) {\r
-      resolver.addSvcLogicRecorder(recorder.getClass().getName(), recorder);\r
-\r
-    }\r
-    for (SvcLogicJavaPlugin plugin : plugins) {\r
-      resolver.addSvcLogicSvcLogicJavaPlugin(plugin.getClass().getName(), plugin);\r
-\r
-    }\r
-    return new SvcLogicServiceImplBase(getStore(), resolver);\r
-  }\r
-\r
-  @Bean\r
-  public Slf4jRecorder slf4jRecorderNode() {\r
-    return new Slf4jRecorder();\r
-  }\r
-\r
-  @Bean\r
-  public SliPluginUtils sliPluginUtil() {\r
-    return new SliPluginUtils();\r
-  }\r
-\r
-  @Bean\r
-  public SliStringUtils sliStringUtils() {\r
-    return new SliStringUtils();\r
-  }\r
-  \r
-  @Bean\r
-  public RestapiCallNode restapiCallNode() {\r
-      return new RestapiCallNode();\r
-  }\r
-  \r
-  @Bean\r
-  public PropertiesNode propertiesNode() {\r
-      return new PropertiesNode();\r
-  }\r
-\r
-}\r