2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.onap.sdnc.config.generator;
26 import com.att.eelf.configuration.EELFLogger;
27 import com.att.eelf.configuration.EELFManager;
28 import java.util.LinkedList;
29 import java.util.List;
30 import org.onap.sdnc.config.generator.convert.ConvertNode;
31 import org.onap.sdnc.config.generator.merge.MergeNode;
32 import org.onap.sdnc.config.generator.pattern.PatternNode;
33 import org.onap.sdnc.config.generator.reader.ReaderNode;
34 import org.onap.sdnc.config.generator.writer.FileWriterNode;
35 import org.osgi.framework.BundleActivator;
36 import org.osgi.framework.BundleContext;
37 import org.osgi.framework.ServiceRegistration;
39 public class ConfigGeneratorActivator implements BundleActivator {
41 private static final String STR_REGISTERING_SERVICE = "Registering service ";
42 private static final String STR_REGISTERING_SERVICE_SUCCESS = "Registering service successful for ";
43 private List<ServiceRegistration> registrations = new LinkedList<>();
45 private static final EELFLogger log =
46 EELFManager.getInstance().getLogger(ConfigGeneratorActivator.class);
49 public void start(BundleContext ctx) throws Exception {
51 ConvertNode convertNode = new ConvertNode();
52 log.info(STR_REGISTERING_SERVICE + convertNode.getClass().getName());
53 registrations.add(ctx.registerService(convertNode.getClass().getName(), convertNode, null));
54 log.info(STR_REGISTERING_SERVICE_SUCCESS + convertNode.getClass().getName());
56 MergeNode mergeNode = new MergeNode();
57 log.info(STR_REGISTERING_SERVICE + mergeNode.getClass().getName());
58 registrations.add(ctx.registerService(mergeNode.getClass().getName(), mergeNode, null));
59 log.info(STR_REGISTERING_SERVICE_SUCCESS + mergeNode.getClass().getName());
61 PatternNode patternNode = new PatternNode();
62 log.info(STR_REGISTERING_SERVICE + patternNode.getClass().getName());
63 registrations.add(ctx.registerService(patternNode.getClass().getName(), patternNode, null));
64 log.info(STR_REGISTERING_SERVICE_SUCCESS + patternNode.getClass().getName());
66 ReaderNode readerNode = new ReaderNode();
67 log.info(STR_REGISTERING_SERVICE + readerNode.getClass().getName());
68 registrations.add(ctx.registerService(readerNode.getClass().getName(), readerNode, null));
69 log.info(STR_REGISTERING_SERVICE_SUCCESS + readerNode.getClass().getName());
71 FileWriterNode writerNode = new FileWriterNode();
72 log.info(STR_REGISTERING_SERVICE + writerNode.getClass().getName());
73 registrations.add(ctx.registerService(writerNode.getClass().getName(), writerNode, null));
74 log.info(STR_REGISTERING_SERVICE_SUCCESS + writerNode.getClass().getName());
79 public void stop(BundleContext arg0) throws Exception {
80 for (ServiceRegistration registration : registrations) {
81 registration.unregister();