2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl;
24 import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.FactoryRegistration;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
31 * @author Shabnam Sultana
33 * Class to initialize the OpenRoadm Device Manager
35 public class DeviceManagerOpenroadmImpl implements AutoCloseable {
38 private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerOpenroadmImpl.class);
39 private static final String APPLICATION_NAME = "DeviceManagerOpenRoadm";
40 @SuppressWarnings("unused")
41 private static final String CONFIGURATIONFILE = "etc/devicemanager-opeenroadm.properties";
42 private NetconfNetworkElementService netconfNetworkElementService;
43 private HtDatabaseClient htDatabaseClient;
44 private Boolean devicemanagerInitializationOk = false;
45 private FactoryRegistration<OpenroadmNetworkElementFactory> resOpenRoadm;
50 public DeviceManagerOpenroadmImpl() {
51 LOG.info("Creating provider for {}", APPLICATION_NAME);
54 // end of constructors
57 public void setNetconfNetworkElementService(NetconfNetworkElementService netconfNetworkElementService) {
58 this.netconfNetworkElementService = netconfNetworkElementService;
61 public void init() throws Exception {
63 LOG.info("Session Initiated start {}", APPLICATION_NAME);
65 resOpenRoadm = netconfNetworkElementService.registerBindingNetworkElementFactory(new OpenroadmNetworkElementFactory());
68 netconfNetworkElementService.writeToEventLog(APPLICATION_NAME, "startup", "done");
69 this.devicemanagerInitializationOk = true;
71 LOG.info("Session Initiated end. Initialization done {}", devicemanagerInitializationOk);
76 public void close() throws Exception {
77 LOG.info("closing ...");
78 close(htDatabaseClient);
80 LOG.info("closing done");
82 // end of public methods
86 * Used to close all Services, that should support AutoCloseable Pattern
91 private void close(AutoCloseable... toCloseList) {
92 for (AutoCloseable element : toCloseList) {
93 if (element != null) {
96 } catch (Exception e) {
97 LOG.warn("Fail during close: ", e);
102 // end of private methods