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.adaptors.netbox.lighty;
19 import io.lighty.core.controller.api.AbstractLightyModule;
20 import java.io.IOException;
21 import org.onap.ccsdk.sli.adaptors.netbox.api.NetboxClient;
22 import org.onap.ccsdk.sli.adaptors.netbox.impl.NetboxClientImplLighty;
23 import org.onap.ccsdk.sli.adaptors.netbox.impl.NetboxHttpClientLighty;
24 import org.onap.ccsdk.sli.adaptors.netbox.property.NetboxPropertiesLighty;
25 import org.onap.ccsdk.sli.core.dblib.DbLibService;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
30 * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from
31 * the netbox-client-provider artifact.
33 public class NetboxClientModule extends AbstractLightyModule {
35 private static final Logger LOG = LoggerFactory.getLogger(NetboxClientModule.class);
37 private final DbLibService dbLibService;
39 private NetboxPropertiesLighty netboxProperties;
40 private NetboxHttpClientLighty netboxHttpClient;
41 private NetboxClientImplLighty netboxClient;
43 public NetboxClientModule(DbLibService dbLibService) {
44 this.dbLibService = dbLibService;
48 protected boolean initProcedure() {
49 this.netboxProperties = new NetboxPropertiesLighty();
50 this.netboxHttpClient = new NetboxHttpClientLighty(netboxProperties);
51 this.netboxClient = new NetboxClientImplLighty(netboxHttpClient, dbLibService);
56 protected boolean stopProcedure() {
58 netboxHttpClient.close();
59 } catch (IOException e) {
60 LOG.error("Exception thrown while closing {}!", netboxHttpClient.getClass(), e);
66 public NetboxClient getNetboxClient() {