2 * ============LICENSE_START==========================================
3 * Copyright (c) 2019 PANTHEON.tech s.r.o.
4 * ===================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
11 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
12 * OF ANY KIND, either express or implied. See the License for the specific language governing permissions and
13 * limitations under the License.
14 * ============LICENSE_END============================================
17 package org.onap.ccsdk.sli.northbound.lighty;
19 import io.lighty.core.controller.api.AbstractLightyModule;
20 import org.onap.ccsdk.sli.core.lighty.common.CcsdkLightyUtils;
21 import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
22 import org.onap.ccsdk.sli.northbound.asdcapi.lighty.AsdcApiModule;
23 import org.onap.ccsdk.sli.northbound.dataChange.lighty.DataChangeModule;
24 import org.onap.ccsdk.sli.northbound.lcm.lighty.LcmModule;
25 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
26 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
27 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
32 * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that groups all other LightyModules
33 * from the ccsdk-sli-northbound repository so they can be all treated as one component (for example started/stopped at once).
34 * For more information about the lighty.io visit the website https://lighty.io.
36 public class CcsdkNorhboundLightyModule extends AbstractLightyModule {
38 private static final Logger LOG = LoggerFactory.getLogger(CcsdkNorhboundLightyModule.class);
40 private final SvcLogicService svcLogicService;
41 private final DataBroker dataBroker;
42 private final NotificationPublishService publishService;
43 private final RpcProviderRegistry rpcProviderRegistry;
45 private AsdcApiModule asdcApiModule;
46 private DataChangeModule dataChangeModule;
47 private LcmModule lcmModule;
49 public CcsdkNorhboundLightyModule(SvcLogicService svcLogicService, DataBroker dataBroker,
50 NotificationPublishService publishService, RpcProviderRegistry rpcProviderRegistry) {
52 this.svcLogicService = svcLogicService;
53 this.dataBroker = dataBroker;
54 this.publishService = publishService;
55 this.rpcProviderRegistry = rpcProviderRegistry;
58 protected boolean initProcedure() {
59 LOG.debug("Initializing CCSDK Northbound Lighty module...");
61 this.asdcApiModule = new AsdcApiModule(svcLogicService, dataBroker, publishService, rpcProviderRegistry);
62 if (!CcsdkLightyUtils.startLightyModule(asdcApiModule)) {
63 LOG.error("Unable to start AsdcApiModule in CCSDK Northbound Lighty module!");
67 this.dataChangeModule = new DataChangeModule(svcLogicService, dataBroker, publishService, rpcProviderRegistry);
68 if (!CcsdkLightyUtils.startLightyModule(dataChangeModule)) {
69 LOG.error("Unable to start DataChangeModule in CCSDK Northbound Lighty module!");
73 this.lcmModule = new LcmModule(svcLogicService, dataBroker, publishService, rpcProviderRegistry);
74 if (!CcsdkLightyUtils.startLightyModule(lcmModule)) {
75 LOG.error("Unable to start LcmModule in CCSDK Northbound Lighty module!");
79 LOG.debug("CCSDK Northbound Lighty module was initialized successfully");
83 protected boolean stopProcedure() {
84 LOG.debug("Stopping CCSDK Northbound Lighty module...");
86 boolean stopSuccessful = true;
88 if (!CcsdkLightyUtils.stopLightyModule(lcmModule)) {
89 stopSuccessful = false;
92 if (!CcsdkLightyUtils.stopLightyModule(dataChangeModule)) {
93 stopSuccessful = false;
96 if (!CcsdkLightyUtils.stopLightyModule(asdcApiModule)) {
97 stopSuccessful = false;
100 if (stopSuccessful) {
101 LOG.debug("CCSDK Northbound Lighty module was stopped successfully");
103 LOG.error("CCSDK Northbound Lighty module was not stopped successfully!");
105 return stopSuccessful;
108 public AsdcApiModule getAsdcApiModule() {
109 return asdcApiModule;
112 public DataChangeModule getDataChangeModule() {
113 return dataChangeModule;
116 public LcmModule getLcmModule() {