diff options
author | Matej Perina <matej.perina@pantheon.tech> | 2019-04-03 09:17:40 +0200 |
---|---|---|
committer | Samuel Kontris <samuel.kontris@pantheon.tech> | 2019-08-28 12:18:55 +0200 |
commit | e385a7a1d1934c6a3d22df3c3244678ca415134a (patch) | |
tree | 477dead11f726bd3b61d29e56654eaca49a38b20 /lighty/ccsdk-lighty-module | |
parent | 400d508da587d8c4fd5c19c15437b2fc2213c9b7 (diff) |
Proposal to remove OSGi dependencies from the CCSDK project
Dependencies on the OSGi frameworks and libraries are removed
by integrating the CCSDK project with the lighty.io.
It's a toolkit that allows to use ODL services (in this case
core services and the Restconf) without the dependency
on the Karaf framework and the Blueprint DI.
The ccsdk-lighty-module artifact contains lighty.io module
that groups all other modules from other repositories and
starts/stops them at once.
The ccsdk-lighty-distribution artifact starts
the lighty.io core, Restconf and the CCSDK integrated with
the lighty.io and creates zip distribution with the CCSDK
lighty.io application and necessary libraries.
The distribution-lighty-ubuntu-docker artifact creates
the docker image with the zip distribution from
the ccsdk-lighty-application artifact and necessary
configuration files.
For more information see the README.md file
in the lighty/docs directory.
More info about the lighty.io - https://lighty.io
Change-Id: Id29935c8e2951b400ad3217ff412bc5155384487
Signed-off-by: Matej Perina <matej.perina@pantheon.tech>
Signed-off-by: Samuel Kontris <samuel.kontris@pantheon.tech>
Diffstat (limited to 'lighty/ccsdk-lighty-module')
4 files changed, 589 insertions, 0 deletions
diff --git a/lighty/ccsdk-lighty-module/pom.xml b/lighty/ccsdk-lighty-module/pom.xml new file mode 100755 index 00000000..063a17d0 --- /dev/null +++ b/lighty/ccsdk-lighty-module/pom.xml @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="UTF-8"?> +<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>odlparent-lite</artifactId> + <version>1.4.0-SNAPSHOT</version> + <relativePath/> + </parent> + + <groupId>org.onap.ccsdk.distribution</groupId> + <artifactId>ccsdk-lighty-module</artifactId> + <version>0.6.0-SNAPSHOT</version> + <packaging>jar</packaging> + + <properties> + <jersey.version>2.26</jersey.version> + </properties> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.onap.ccsdk.sli.core</groupId> + <artifactId>ccsdk-lighty-dependency-versions</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>io.lighty.core</groupId> + <artifactId>lighty-controller</artifactId> + </dependency> + <dependency> + <groupId>io.lighty.modules</groupId> + <artifactId>lighty-restconf-nb-community</artifactId> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.sli.core</groupId> + <artifactId>ccsdk-core-lighty</artifactId> + <version>${project.version}</version> + <exclusions> + <exclusion> + <artifactId>org.apache.karaf.jaas.modules</artifactId> + <groupId>org.apache.karaf.jaas</groupId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.sli.adaptors</groupId> + <artifactId>ccsdk-adaptors-lighty</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.sli.northbound</groupId> + <artifactId>ccsdk-northbound-lighty</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.sli.plugins</groupId> + <artifactId>ccsdk-plugins-lighty</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.onap.ccsdk.sli.core</groupId> + <artifactId>sli-recording</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.opendaylight.aaa</groupId> + <artifactId>aaa-encrypt-service</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>4.5.2</version> + </dependency> + <!-- version 2.26 is not backwards compatible - https://stackoverflow.com/a/46405129/4727422 --> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-common</artifactId> + <version>${jersey.version}</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.inject</groupId> + <artifactId>jersey-hk2</artifactId> + <version>${jersey.version}</version> + </dependency> + </dependencies> +</project> diff --git a/lighty/ccsdk-lighty-module/src/main/java/org/onap/ccsdk/distribution/lighty/AAAEncryptionServiceLightyImpl.java b/lighty/ccsdk-lighty-module/src/main/java/org/onap/ccsdk/distribution/lighty/AAAEncryptionServiceLightyImpl.java new file mode 100644 index 00000000..2610544a --- /dev/null +++ b/lighty/ccsdk-lighty-module/src/main/java/org/onap/ccsdk/distribution/lighty/AAAEncryptionServiceLightyImpl.java @@ -0,0 +1,116 @@ +/* + * ============LICENSE_START========================================== + * Copyright (c) 2019 PANTHEON.tech s.r.o. + * =================================================================== + * 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.distribution.lighty; + +import java.nio.charset.Charset; +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.xml.bind.DatatypeConverter; +import org.onap.ccsdk.sli.core.dblib.DBLIBResourceProvider; +import org.onap.ccsdk.sli.core.dblib.DBLIBResourceProviderLighty; +import org.opendaylight.aaa.encrypt.AAAEncryptionService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Custom implementation of the {@link AAAEncryptionService}. Original class {@link DBLIBResourceProvider} was accessing + * instance of this interface via OGSi (BundleContext) and java reflection. The implementation of + * the {@link AAAEncryptionService} has to be injected via constructor into the lighty.io version of the class with + * removed OSGi dependency {@link DBLIBResourceProviderLighty}. + */ +public class AAAEncryptionServiceLightyImpl implements AAAEncryptionService { + + private static final Logger LOG = LoggerFactory.getLogger(AAAEncryptionServiceLightyImpl.class); + + private final Cipher encryptCipher; + private final Cipher decryptCipher; + + public AAAEncryptionServiceLightyImpl(Cipher encryptCipher, Cipher decryptCipher) { + this.encryptCipher = encryptCipher; + this.decryptCipher = decryptCipher; + } + + @Override + public String encrypt(String data) { + if (data != null && data.length() != 0 ) { + try { + synchronized (encryptCipher) { + byte[] cryptobytes = encryptCipher.doFinal(data.getBytes(Charset.defaultCharset())); + String cryptostring = DatatypeConverter.printBase64Binary(cryptobytes); + return cryptostring; + } + } catch (IllegalBlockSizeException | BadPaddingException e) { + LOG.error("Failed to encrypt data.", e); + return data; + } + } else { + LOG.warn("data is empty or null."); + return data; + } + } + + @Override + public byte[] encrypt(byte[] data) { + if (data != null && data.length != 0) { + try { + synchronized (encryptCipher) { + return encryptCipher.doFinal(data); + } + } catch (IllegalBlockSizeException | BadPaddingException e) { + LOG.error("Failed to encrypt data.", e); + return data; + } + } else { + LOG.warn("data is empty or null."); + return data; + } + } + + @Override + public String decrypt(String encryptedData) { + if (encryptedData != null && encryptedData.length() != 0) { + try { + byte[] cryptobytes = DatatypeConverter.parseBase64Binary(encryptedData); + byte[] clearbytes = decryptCipher.doFinal(cryptobytes); + return new String(clearbytes, Charset.defaultCharset()); + } catch (IllegalBlockSizeException | BadPaddingException e) { + LOG.error("Failed to decrypt encoded data", e); + return encryptedData; + } + } else { + LOG.warn("encryptedData is empty or null."); + return encryptedData; + } + } + + @Override + public byte[] decrypt(byte[] encryptedData) { + if (encryptedData != null && encryptedData.length != 0) { + try { + return decryptCipher.doFinal(encryptedData); + } catch (IllegalBlockSizeException | BadPaddingException e) { + LOG.error("Failed to decrypt encoded data", e); + return encryptedData; + } + } else { + LOG.warn("encryptedData is empty or null."); + return encryptedData; + } + } + +} diff --git a/lighty/ccsdk-lighty-module/src/main/java/org/onap/ccsdk/distribution/lighty/CcsdkLightyApplication.java b/lighty/ccsdk-lighty-module/src/main/java/org/onap/ccsdk/distribution/lighty/CcsdkLightyApplication.java new file mode 100644 index 00000000..efecb3f1 --- /dev/null +++ b/lighty/ccsdk-lighty-module/src/main/java/org/onap/ccsdk/distribution/lighty/CcsdkLightyApplication.java @@ -0,0 +1,170 @@ +/* + * ============LICENSE_START========================================== + * Copyright (c) 2019 PANTHEON.tech s.r.o. + * =================================================================== + * 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.distribution.lighty; + +import io.lighty.core.controller.api.AbstractLightyModule; +import io.lighty.core.controller.api.LightyController; +import io.lighty.core.controller.impl.LightyControllerBuilder; +import io.lighty.core.controller.impl.config.ConfigurationException; +import io.lighty.core.controller.impl.config.ControllerConfiguration; +import io.lighty.modules.northbound.restconf.community.impl.CommunityRestConf; +import io.lighty.modules.northbound.restconf.community.impl.CommunityRestConfBuilder; +import io.lighty.modules.northbound.restconf.community.impl.config.RestConfConfiguration; +import io.lighty.modules.northbound.restconf.community.impl.util.RestConfConfigUtils; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.KeySpec; +import java.util.Base64; +import javax.crypto.Cipher; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.SecretKey; +import javax.crypto.SecretKeyFactory; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.PBEKeySpec; +import javax.crypto.spec.SecretKeySpec; +import org.onap.ccsdk.sli.core.lighty.common.CcsdkLightyUtils; +import org.opendaylight.aaa.encrypt.AAAEncryptionService; +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.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.config.aaa.authn.encrypt.service.config.rev160915.AaaEncryptServiceConfig; +import org.opendaylight.yang.gen.v1.config.aaa.authn.encrypt.service.config.rev160915.AaaEncryptServiceConfigBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that groups all necessary components + * needed to start the CCSDK lighty.io application. + */ +public class CcsdkLightyApplication extends AbstractLightyModule { + + private static final Logger LOG = LoggerFactory.getLogger(CcsdkLightyApplication.class); + + private ControllerConfiguration controllerConfiguration; + private RestConfConfiguration restConfConfiguration; + + private LightyController lightyController; + private CommunityRestConf communityRestConf; + private CcsdkLightyModule ccsdkLightyModule; + + public CcsdkLightyApplication(ControllerConfiguration controllerConfiguration, + RestConfConfiguration restConfConfiguration) { + this.controllerConfiguration = controllerConfiguration; + this.restConfConfiguration = restConfConfiguration; + } + + @Override + protected boolean initProcedure() { + // Start Lighty Controller with base OLD services + LightyControllerBuilder lightyControllerBuilder = new LightyControllerBuilder(); + try { + lightyController = lightyControllerBuilder.from(controllerConfiguration).build(); + } catch (ConfigurationException e) { + LOG.error("Exception thrown while starting Lighty controller!", e); + return false; + } + if (!CcsdkLightyUtils.startLightyModule(lightyController)) { + LOG.error("Unable to start Lighty controller!"); + return false; + } + + // Start RestConf + CommunityRestConfBuilder communityRestConfBuilder = new CommunityRestConfBuilder(); + communityRestConf = communityRestConfBuilder + .from(RestConfConfigUtils.getRestConfConfiguration(restConfConfiguration, + lightyController.getServices())) + .build(); + if (!CcsdkLightyUtils.startLightyModule(communityRestConf)) { + LOG.error("Unable to start RestConf!"); + return false; + } + + // Start Lighty CCSDK + AAAEncryptionService aaaEncryptionService = null; + try { + aaaEncryptionService = createAAAEncryptionService(getDefaultAaaEncryptServiceConfig()); + } catch (ConfigurationException e) { + LOG.error("Exception thrown while initializing {}!", AAAEncryptionService.class, e); + } + DataBroker dataBroker = lightyController.getServices().getControllerBindingDataBroker(); + NotificationPublishService notificationPublishService = lightyController.getServices() + .getControllerBindingNotificationPublishService(); + RpcProviderRegistry rpcProviderRegistry = lightyController.getServices().getControllerRpcProviderRegistry(); + ccsdkLightyModule = new CcsdkLightyModule(dataBroker, notificationPublishService, + rpcProviderRegistry, aaaEncryptionService); + if (!CcsdkLightyUtils.startLightyModule(ccsdkLightyModule)) { + LOG.error("Unable to start CCSDK Lighty module!"); + return false; + } + + return true; + } + + @Override + protected boolean stopProcedure() { + boolean stopSuccessful = true; + + if (!CcsdkLightyUtils.stopLightyModule(ccsdkLightyModule)) { + stopSuccessful = false; + } + + if (!CcsdkLightyUtils.stopLightyModule(communityRestConf)) { + stopSuccessful = false; + } + + if (!CcsdkLightyUtils.stopLightyModule(lightyController)) { + stopSuccessful = false; + } + + return stopSuccessful; + } + + private AAAEncryptionService createAAAEncryptionService(AaaEncryptServiceConfig encrySrvConfig) + throws ConfigurationException { + final byte[] encryptionKeySalt = Base64.getDecoder().decode(encrySrvConfig.getEncryptSalt()); + try { + final SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(encrySrvConfig.getEncryptMethod()); + final KeySpec keySpec = new PBEKeySpec(encrySrvConfig.getEncryptKey().toCharArray(), encryptionKeySalt, + encrySrvConfig.getEncryptIterationCount(), encrySrvConfig.getEncryptKeyLength()); + SecretKey key = new SecretKeySpec(keyFactory.generateSecret(keySpec).getEncoded(), + encrySrvConfig.getEncryptType()); + IvParameterSpec ivParameterSpec = new IvParameterSpec(encryptionKeySalt); + + Cipher encryptCipher = Cipher.getInstance(encrySrvConfig.getCipherTransforms()); + encryptCipher.init(Cipher.ENCRYPT_MODE, key, ivParameterSpec); + + Cipher decryptCipher = Cipher.getInstance(encrySrvConfig.getCipherTransforms()); + decryptCipher.init(Cipher.DECRYPT_MODE, key, ivParameterSpec); + + return new AAAEncryptionServiceLightyImpl(encryptCipher, decryptCipher); + + } catch (NoSuchAlgorithmException | InvalidKeySpecException | NoSuchPaddingException + | InvalidAlgorithmParameterException | InvalidKeyException e) { + throw new ConfigurationException(e); + } + } + + private AaaEncryptServiceConfig getDefaultAaaEncryptServiceConfig() { + return new AaaEncryptServiceConfigBuilder().setEncryptKey("V1S1ED4OMeEh") + .setPasswordLength(12).setEncryptSalt("TdtWeHbch/7xP52/rp3Usw==") + .setEncryptMethod("PBKDF2WithHmacSHA1").setEncryptType("AES") + .setEncryptIterationCount(32768).setEncryptKeyLength(128) + .setCipherTransforms("AES/CBC/PKCS5Padding").build(); + } +} diff --git a/lighty/ccsdk-lighty-module/src/main/java/org/onap/ccsdk/distribution/lighty/CcsdkLightyModule.java b/lighty/ccsdk-lighty-module/src/main/java/org/onap/ccsdk/distribution/lighty/CcsdkLightyModule.java new file mode 100644 index 00000000..061afc8b --- /dev/null +++ b/lighty/ccsdk-lighty-module/src/main/java/org/onap/ccsdk/distribution/lighty/CcsdkLightyModule.java @@ -0,0 +1,206 @@ +/* + * ============LICENSE_START========================================== + * Copyright (c) 2019 PANTHEON.tech s.r.o. + * =================================================================== + * 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.distribution.lighty; + +import com.google.common.collect.ImmutableSet; +import io.lighty.core.controller.api.AbstractLightyModule; +import java.util.Set; +import org.onap.ccsdk.sli.adaptors.lighty.CcsdkAdaptorsLightyModule; +import org.onap.ccsdk.sli.core.dblib.lighty.DblibModule; +import org.onap.ccsdk.sli.core.lighty.common.CcsdkLightyUtils; +import org.onap.ccsdk.sli.core.sli.lighty.SliModule; +import org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder; +import org.onap.ccsdk.sli.core.sliapi.lighty.SliApiModule; +import org.onap.ccsdk.sli.core.slipluginutils.lighty.SliPluginUtilsModule; +import org.onap.ccsdk.sli.northbound.lighty.CcsdkNorhboundLightyModule; +import org.onap.ccsdk.sli.plugins.lighty.CcsdkPluginsLightyModule; +import org.opendaylight.aaa.encrypt.AAAEncryptionService; +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.RpcProviderRegistry; +import org.opendaylight.yangtools.yang.binding.YangModuleInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that groups all other LightyModules + * from the CCSDK project so they can be all treated as one component (for example started/stopped at once). + * For more information about the lighty.io visit the website https://lighty.io. + */ +public class CcsdkLightyModule extends AbstractLightyModule { + + private static final Logger LOG = LoggerFactory.getLogger(CcsdkLightyModule.class); + + public static final Set<YangModuleInfo> YANG_MODELS = ImmutableSet.of( + org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.$YangModuleInfoImpl.getInstance(), + org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.$YangModuleInfoImpl.getInstance(), + org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.datachange.rev150519.$YangModuleInfoImpl.getInstance(), + org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.asdcapi.common.rev170201.$YangModuleInfoImpl.getInstance(), + org.opendaylight.yang.gen.v1.http.xmlns.onap.org.asdc.license.model._1._0.rev160427.$YangModuleInfoImpl.getInstance(), + org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.$YangModuleInfoImpl.getInstance() + ); + + private final DataBroker dataBroker; + private final NotificationPublishService notificationPublishService; + private final RpcProviderRegistry rpcProviderRegistry; + private final AAAEncryptionService aaaEncryptionService; + + private CcsdkAdaptorsLightyModule ccsdkAdaptorsLightyModule; + private CcsdkNorhboundLightyModule ccsdkNorhboundLightyModule; + private CcsdkPluginsLightyModule ccsdkPluginsLightyModule; + private DblibModule dblibModule; + private SliModule sliModule; + private SliApiModule sliApiModule; + private SliPluginUtilsModule sliPluginUtilsModule; + + public CcsdkLightyModule(DataBroker dataBroker, NotificationPublishService notificationPublishService, + RpcProviderRegistry rpcProviderRegistry, AAAEncryptionService aaaEncryptionService) { + this.dataBroker = dataBroker; + this.notificationPublishService = notificationPublishService; + this.rpcProviderRegistry = rpcProviderRegistry; + this.aaaEncryptionService = aaaEncryptionService; + } + + protected boolean initProcedure() { + // FIXME modules from CcsdkCoreLightyModule need to be started separately (not through CcsdkCoreLightyModule + // itself) because SliApiModule is dependent on the adaptors + try { + LOG.debug("Initializing CCSDK Lighty module..."); + + this.dblibModule = new DblibModule(aaaEncryptionService); + if (!CcsdkLightyUtils.startLightyModule(dblibModule)) { + LOG.error("Unable to start DblibModule in CCSDK Core Lighty module!"); + return false; + } + + this.ccsdkAdaptorsLightyModule = new CcsdkAdaptorsLightyModule(dblibModule.getDbLibService()); + if (!CcsdkLightyUtils.startLightyModule(ccsdkAdaptorsLightyModule)) { + LOG.error("Unable to start CcsdkAdaptorsLightyModule in CCSDK Lighty module!"); + return false; + } + + this.sliModule = new SliModule(dblibModule.getDbLibService(), + ccsdkAdaptorsLightyModule.getAaaServiceModule().getAAIService(), new Slf4jRecorder(), + ccsdkAdaptorsLightyModule.getAaaServiceModule().getAAIService(), null); + if (!CcsdkLightyUtils.startLightyModule(sliModule)) { + LOG.error("Unable to start SliModule in CCSDK Core Lighty module!"); + return false; + } + + this.sliApiModule = new SliApiModule(dataBroker, notificationPublishService, rpcProviderRegistry, sliModule.getSvcLogicServiceImpl()); + if (!CcsdkLightyUtils.startLightyModule(sliApiModule)) { + LOG.error("Unable to start SliApiModule in CCSDK Core Lighty module!"); + return false; + } + + this.sliPluginUtilsModule = new SliPluginUtilsModule(); + if (!CcsdkLightyUtils.startLightyModule(sliPluginUtilsModule)) { + LOG.error("Unable to start SliPluginUtilsModule in CCSDK Core Lighty module!"); + return false; + } + + this.ccsdkPluginsLightyModule = new CcsdkPluginsLightyModule(); + if (!CcsdkLightyUtils.startLightyModule(ccsdkPluginsLightyModule)) { + LOG.error("Unable to start CcsdkPluginsLightyModule in CCSDK Lighty module!"); + return false; + } + + this.ccsdkNorhboundLightyModule = + new CcsdkNorhboundLightyModule(sliModule.getSvcLogicServiceImpl(), dataBroker, + notificationPublishService, rpcProviderRegistry); + if (!CcsdkLightyUtils.startLightyModule(ccsdkNorhboundLightyModule)) { + LOG.error("Unable to start CcsdkNorhboundLightyModule in CCSDK Lighty module!"); + return false; + } + + LOG.debug("CCSDK Lighty module was initialized successfully"); + return true; + } catch (Exception e) { + LOG.error("Exception caught!", e); + throw e; + } + } + + protected boolean stopProcedure() { + LOG.debug("Stopping CCSDK Lighty module..."); + + boolean stopSuccessful = true; + + if (!CcsdkLightyUtils.stopLightyModule(ccsdkPluginsLightyModule)) { + stopSuccessful = false; + } + + if (!CcsdkLightyUtils.stopLightyModule(ccsdkNorhboundLightyModule)) { + stopSuccessful = false; + } + + if (!CcsdkLightyUtils.stopLightyModule(ccsdkAdaptorsLightyModule)) { + stopSuccessful = false; + } + + if (!CcsdkLightyUtils.stopLightyModule(sliPluginUtilsModule)) { + stopSuccessful = false; + } + + if (!CcsdkLightyUtils.stopLightyModule(sliApiModule)) { + stopSuccessful = false; + } + + if (!CcsdkLightyUtils.stopLightyModule(sliModule)) { + stopSuccessful = false; + } + + if (!CcsdkLightyUtils.stopLightyModule(dblibModule)) { + stopSuccessful = false; + } + + if (stopSuccessful) { + LOG.debug("CCSDK Lighty module was stopped successfully"); + } else { + LOG.error("CCSDK Lighty module was not stopped successfully!"); + } + return stopSuccessful; + } + + public CcsdkAdaptorsLightyModule getCcsdkAdaptorsLightyModule() { + return ccsdkAdaptorsLightyModule; + } + + public CcsdkNorhboundLightyModule getCcsdkNorhboundLightyModule() { + return ccsdkNorhboundLightyModule; + } + + public CcsdkPluginsLightyModule getCcsdkPluginsLightyModule() { + return ccsdkPluginsLightyModule; + } + + public DblibModule getDblibModule() { + return dblibModule; + } + + public SliModule getSliModule() { + return sliModule; + } + + public SliApiModule getSliApiModule() { + return sliApiModule; + } + + public SliPluginUtilsModule getSliPluginUtilsModule() { + return sliPluginUtilsModule; + } +} |