Merge "BUG-2470: add trace of failed modification"
[controller.git] / opendaylight / adsal / northbound / bundlescanner / implementation / src / main / java / org / opendaylight / controller / northbound / bundlescanner / internal / Activator.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.northbound.bundlescanner.internal;
10
11 import org.apache.felix.dm.Component;
12 import org.opendaylight.controller.northbound.bundlescanner.IBundleScanService;
13 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
14 import org.osgi.framework.BundleContext;
15 import org.osgi.framework.FrameworkUtil;
16
17 /**
18  * The activator registers the BundleScanner.
19  */
20 public class Activator extends ComponentActivatorAbstractBase {
21
22     @Override
23     protected void init() {
24         BundleContext context = FrameworkUtil.getBundle(BundleScanner.class).getBundleContext();
25         context.addBundleListener(BundleScanner.getInstance());
26     }
27
28     @Override
29     public void destroy() {
30         BundleContext context = FrameworkUtil.getBundle(BundleScanner.class).getBundleContext();
31         context.removeBundleListener(BundleScanner.getInstance());
32     }
33
34     @Override
35     protected Object[] getGlobalImplementations() {
36         return new Object[] { BundleScanServiceImpl.class };
37     }
38
39     @Override
40     protected void configureGlobalInstance(Component c, Object imp) {
41         if (!imp.equals(BundleScanServiceImpl.class)) {
42             return;
43         }
44         // export service
45         c.setInterface(
46                 new String[] { IBundleScanService.class.getName() },
47                 null);
48     }
49
50 }