2f58d1f75b5b57d99dcda20b7b10cb9480cd3b24
[ccsdk/sli/adaptors.git] /
1 /*
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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============================================
15  *
16  */
17 package org.onap.ccsdk.sli.adaptors.saltstack.lighty;
18
19 import io.lighty.core.controller.api.AbstractLightyModule;
20 import org.onap.ccsdk.sli.adaptors.saltstack.SaltstackAdapter;
21 import org.onap.ccsdk.sli.adaptors.saltstack.impl.SaltstackAdapterImpl;
22 import org.onap.ccsdk.sli.adaptors.saltstack.impl.SaltstackAdapterPropertiesProviderImplLighty;
23 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26
27 /**
28  * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from
29  * the saltstack-adapter-provider artifact.
30  */
31 public class SaltstackAdapterModule extends AbstractLightyModule {
32
33     private static final Logger LOG = LoggerFactory.getLogger(SaltstackAdapterModule.class);
34
35     private SaltstackAdapterPropertiesProviderImplLighty salstackPropertiesProvider;
36     private SaltstackAdapterImpl saltstackAdapter;
37
38     @Override
39     protected boolean initProcedure() {
40         this.salstackPropertiesProvider = new SaltstackAdapterPropertiesProviderImplLighty();
41         try {
42             this.saltstackAdapter = new SaltstackAdapterImpl(salstackPropertiesProvider);
43         } catch (SvcLogicException e) {
44             LOG.error("Exception thrown while initializing {} in {}!", SaltstackAdapterImpl.class, this.getClass(), e);
45         }
46         return true;
47     }
48
49     @Override
50     protected boolean stopProcedure() {
51         return true;
52     }
53
54     public SaltstackAdapterPropertiesProviderImplLighty getSalstackPropertiesProvider() {
55         return this.salstackPropertiesProvider;
56     }
57
58     public SaltstackAdapter getSaltstackAdapter() {
59         return saltstackAdapter;
60     }
61 }