fe9f9d450eafaea5ae72434379ed1b32784aa7ba
[sdnc/northbound.git] / vnftools / provider / src / main / java / org / onap / sdnc / vnftools / VnfToolsActivator.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : SDN-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                                                      reserved.
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
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  */
21
22 package org.onap.sdnc.vnftools;
23
24 import java.io.File;
25 import java.io.FileInputStream;
26 import java.util.LinkedList;
27 import java.util.List;
28 import java.util.Properties;
29
30 import org.onap.ccsdk.sli.core.sli.ConfigurationException;
31 import org.osgi.framework.BundleActivator;
32 import org.osgi.framework.BundleContext;
33 import org.osgi.framework.ServiceRegistration;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
36
37 public class VnfToolsActivator implements BundleActivator {
38
39         private static final String VNFTOOLS_PROP_VAR = "/vnftools.properties";
40         private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
41
42         @SuppressWarnings("rawtypes")
43         private List<ServiceRegistration> registrations = new LinkedList<ServiceRegistration>();
44
45         private static final Logger LOG = LoggerFactory.getLogger(VnfToolsActivator.class);
46
47         @Override
48         public void start(BundleContext ctx) throws Exception {
49
50                 VnfTools plugin = new VnfTools(null);
51
52                 LOG.info("Registering service " + plugin.getClass().getName());
53                 registrations.add(ctx.registerService(plugin.getClass().getName(), plugin, null));
54         }
55
56         @Override
57         public void stop(BundleContext ctx) throws Exception {
58
59                 for (@SuppressWarnings("rawtypes")
60                 ServiceRegistration registration : registrations) {
61                         registration.unregister();
62                         registration = null;
63                 }
64         }
65
66 }