aboutsummaryrefslogtreecommitdiffstats
path: root/services/src/main/java/org/onap/ccsdk/apps/services/SvcLogicFactory.java
diff options
context:
space:
mode:
Diffstat (limited to 'services/src/main/java/org/onap/ccsdk/apps/services/SvcLogicFactory.java')
-rw-r--r--services/src/main/java/org/onap/ccsdk/apps/services/SvcLogicFactory.java247
1 files changed, 127 insertions, 120 deletions
diff --git a/services/src/main/java/org/onap/ccsdk/apps/services/SvcLogicFactory.java b/services/src/main/java/org/onap/ccsdk/apps/services/SvcLogicFactory.java
index 9ab5656c..54d612f6 100644
--- a/services/src/main/java/org/onap/ccsdk/apps/services/SvcLogicFactory.java
+++ b/services/src/main/java/org/onap/ccsdk/apps/services/SvcLogicFactory.java
@@ -20,8 +20,11 @@
package org.onap.ccsdk.apps.services;
+import java.io.File;
import java.io.FileInputStream;
+import java.io.FileReader;
import java.io.IOException;
+import java.io.InputStream;
import java.util.List;
import java.util.Properties;
@@ -41,6 +44,8 @@ import org.onap.ccsdk.sli.core.dblib.DBLIBResourceProvider;
import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
import org.onap.ccsdk.sli.core.dblib.DbLibService;
import org.onap.ccsdk.sli.core.sli.ConfigurationException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
import org.onap.ccsdk.sli.core.sli.SvcLogicLoader;
import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder;
@@ -67,147 +72,149 @@ import org.springframework.stereotype.Service;
@Configuration
@Service
public class SvcLogicFactory {
- private static final Logger log = LoggerFactory.getLogger(SvcLogicFactory.class);
-
- @Autowired
- List<SvcLogicRecorder> recorders;
-
- @Autowired
- List<SvcLogicJavaPlugin> plugins;
-
- @Autowired
- List<SvcLogicResource> svcLogicResources;
+ private static final Logger log = LoggerFactory.getLogger(SvcLogicFactory.class);
+ private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
+ private static final String CONTRAIL_PROPERTIES = "contrail-adaptor.properties";
+
+ @Autowired
+ List<SvcLogicRecorder> recorders;
+
+ @Autowired
+ List<SvcLogicJavaPlugin> plugins;
+
+ @Autowired
+ List<SvcLogicResource> svcLogicResources;
+
+
+ @Bean
+ public SvcLogicStore getStore() throws Exception {
+ SvcLogicPropertiesProvider propProvider = new SvcLogicPropertiesProvider() {
+
+ @Override
+ public Properties getProperties() {
+ Properties props = new Properties();
+
+ String propPath = System.getProperty("serviceLogicProperties", "");
+
+ if ("".equals(propPath)) {
+ propPath = System.getenv("SVCLOGIC_PROPERTIES");
+ }
+
+ if ((propPath == null) || propPath.length() == 0) {
+ propPath = "src/main/resources/svclogic.properties";
+ }
+ System.out.println(propPath);
+ try (FileInputStream fileInputStream = new FileInputStream(propPath)) {
+ props = new EnvProperties();
+ props.load(fileInputStream);
+ } catch (final IOException e) {
+ log.error("Failed to load properties for file: {}", propPath,
+ new ConfigurationException("Failed to load properties for file: " + propPath, e));
+ }
+ return props;
+ }
+ };
+ SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propProvider.getProperties());
+ return store;
+ }
- @Bean
- public SvcLogicStore getStore() throws Exception {
- SvcLogicPropertiesProvider propProvider = new SvcLogicPropertiesProvider() {
+ @Bean
+ public SvcLogicLoader createLoader() throws Exception {
+ String serviceLogicDirectory = System.getProperty("serviceLogicDirectory");
+ if (serviceLogicDirectory == null) {
+ serviceLogicDirectory = "src/main/resources";
+ }
- @Override
- public Properties getProperties() {
- Properties props = new Properties();
+ System.out.println("serviceLogicDirectory is " + serviceLogicDirectory);
+ SvcLogicLoader loader = new SvcLogicLoader(serviceLogicDirectory, getStore());
+ try {
+ loader.loadAndActivate();
+ } catch (IOException e) {
+ log.error("Cannot load directed graphs", e);
+ }
+ return loader;
+ }
- String propPath = System.getProperty("serviceLogicProperties", "");
+ @Bean
+ public SvcLogicServiceBase createService() throws Exception {
+ HashMapResolver resolver = new HashMapResolver();
+ for (SvcLogicRecorder recorder : recorders) {
+ log.info("Registering SvcLogicRecorder {}", recorder.getClass().getName());
+ resolver.addSvcLogicRecorder(recorder.getClass().getName(), recorder);
- if ("".equals(propPath)) {
- propPath = System.getenv("SVCLOGIC_PROPERTIES");
}
+ for (SvcLogicJavaPlugin plugin : plugins) {
+ log.info("Registering SvcLogicJavaPlugin {}", plugin.getClass().getName());
+ resolver.addSvcLogicSvcLogicJavaPlugin(plugin.getClass().getName(), plugin);
- if ((propPath == null) || propPath.length() == 0) {
- propPath = "src/main/resources/svclogic.properties";
}
- System.out.println(propPath);
- try (FileInputStream fileInputStream = new FileInputStream(propPath)) {
- props = new EnvProperties();
- props.load(fileInputStream);
- } catch (final IOException e) {
- log.error("Failed to load properties for file: {}", propPath,
- new ConfigurationException("Failed to load properties for file: " + propPath, e));
+ for (SvcLogicResource svcLogicResource : svcLogicResources) {
+ log.info("Registering SvcLogicResource {}", svcLogicResource.getClass().getName());
+ resolver.addSvcLogicResource(svcLogicResource.getClass().getName(), svcLogicResource);
}
- return props;
- }
- };
- SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propProvider.getProperties());
- return store;
- }
-
- @Bean
- public SvcLogicLoader createLoader() throws Exception {
- String serviceLogicDirectory = System.getProperty("serviceLogicDirectory");
- if (serviceLogicDirectory == null) {
- serviceLogicDirectory = "src/main/resources";
+
+ return new SvcLogicServiceImplBase(getStore(), resolver);
}
- System.out.println("serviceLogicDirectory is " + serviceLogicDirectory);
- SvcLogicLoader loader = new SvcLogicLoader(serviceLogicDirectory, getStore());
+ @Bean
+ public Slf4jRecorder slf4jRecorderNode() {
+ return new Slf4jRecorder();
+ }
- try {
- loader.loadAndActivate();
- } catch (IOException e) {
- log.error("Cannot load directed graphs", e);
+ // Beans from sli/core
+
+ @Bean
+ public SliPluginUtils sliPluginUtil() {
+ return new SliPluginUtils();
}
- return loader;
- }
- @Bean
- public SvcLogicServiceBase createService() throws Exception {
- HashMapResolver resolver = new HashMapResolver();
- for (SvcLogicRecorder recorder : recorders) {
- resolver.addSvcLogicRecorder(recorder.getClass().getName(), recorder);
+ @Bean
+ public SliStringUtils sliStringUtils() {
+ return new SliStringUtils();
+ }
+ // Beans from sli/adaptors
+
+ @Bean
+ AAIService aaiService() {
+ return new AAIService(new AAIServiceProvider());
+ }
+
+ @Bean
+ public ConfigResource configResource() {
+ return new ConfigResource(new MdsalResourcePropertiesProviderImpl());
+ }
+
+ @Bean
+ public OperationalResource operationalResource() {
+ return new OperationalResource(new MdsalResourcePropertiesProviderImpl());
}
- for (SvcLogicJavaPlugin plugin : plugins) {
- resolver.addSvcLogicSvcLogicJavaPlugin(plugin.getClass().getName(), plugin);
+ @Bean
+ public PublisherApi publisherApi() {
+ return new PublisherApiImpl();
}
- for (SvcLogicResource svcLogicResource : svcLogicResources) {
- resolver.addSvcLogicResource(svcLogicResource.getClass().getName(), svcLogicResource);
+
+ @Bean
+ public NetboxClient netboxClient() {
+ return new NetboxClientImpl();
}
- return new SvcLogicServiceImplBase(getStore(), resolver);
- }
-
- @Bean
- public Slf4jRecorder slf4jRecorderNode() {
- return new Slf4jRecorder();
- }
-
- // Beans from sli/core
-
- @Bean
- public SliPluginUtils sliPluginUtil() {
- return new SliPluginUtils();
- }
-
- @Bean
- public SliStringUtils sliStringUtils() {
- return new SliStringUtils();
- }
-
- // Beans from sli/adaptors
-
- @Bean AAIService aaiService() {
- return new AAIService(new AAIServiceProvider());
- }
-
- @Bean
- public ConfigResource configResource() {
- return new ConfigResource(new MdsalResourcePropertiesProviderImpl());
- }
-
- @Bean
- public OperationalResource operationalResource() {
- return new OperationalResource(new MdsalResourcePropertiesProviderImpl());
- }
-
- @Bean
- public PublisherApi publisherApi() {
- return new PublisherApiImpl();
- }
-
-
- @Bean
- public NetboxClient netboxClient() {
- return new NetboxClientImpl();
- }
-
-
- @Bean
- public SqlResource sqlResource() {
- return new SqlResource();
- }
-
-
- @Bean
- public RestapiCallNode restapiCallNode() {
- return new RestapiCallNode();
- }
-
- @Bean
- public PropertiesNode propertiesNode() {
- return new PropertiesNode();
- }
+ @Bean
+ public SqlResource sqlResource() {
+ return new SqlResource();
+ }
+ @Bean
+ public RestapiCallNode restapiCallNode() {
+ return new RestapiCallNode();
+ }
+
+ @Bean
+ public PropertiesNode propertiesNode() {
+ return new PropertiesNode();
+ }
}