Merge "Prevent ConfigPusher from killing its thread"
[controller.git] / opendaylight / switchmanager / implementation / src / main / java / org / opendaylight / controller / switchmanager / internal / Activator.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.switchmanager.internal;
11
12 import org.apache.felix.dm.Component;
13 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
14 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
15 import org.opendaylight.controller.configuration.IConfigurationContainerService;
16 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
17 import org.opendaylight.controller.sal.inventory.IInventoryService;
18 import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates;
19 import org.opendaylight.controller.statisticsmanager.IStatisticsManager;
20 import org.opendaylight.controller.switchmanager.IInventoryListener;
21 import org.opendaylight.controller.switchmanager.ISpanAware;
22 import org.opendaylight.controller.switchmanager.ISwitchManager;
23 import org.opendaylight.controller.switchmanager.ISwitchManagerAware;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26
27 /**
28  * SwitchManager Bundle Activator
29  *
30  *
31  */
32 public class Activator extends ComponentActivatorAbstractBase {
33     protected static final Logger logger = LoggerFactory
34             .getLogger(Activator.class);
35
36
37     /**
38      * Function that is used to communicate to dependency manager the
39      * list of known implementations for services inside a container
40      *
41      *
42      * @return An array containing all the CLASS objects that will be
43      * instantiated in order to get an fully working implementation
44      * Object
45      */
46     @Override
47     public Object[] getImplementations() {
48         Object[] res = { SwitchManager.class };
49         return res;
50     }
51
52     /**
53      * Function that is called when configuration of the dependencies
54      * is required.
55      *
56      * @param c dependency manager Component object, used for
57      * configuring the dependencies exported and imported
58      * @param imp Implementation class that is being configured,
59      * needed as long as the same routine can configure multiple
60      * implementations
61      * @param containerName The containerName being configured, this allow
62      * also optional per-container different behavior if needed, usually
63      * should not be the case though.
64      */
65     @Override
66     public void configureInstance(Component c, Object imp, String containerName) {
67         if (imp.equals(SwitchManager.class)) {
68             // export the service
69             c.setInterface(new String[] {
70                     IListenInventoryUpdates.class.getName(),
71                     ISwitchManager.class.getName(),
72                     IConfigurationContainerAware.class.getName() }, null);
73
74             // Now lets add a service dependency to make sure the
75             // provider of service exists
76             c.add(createContainerServiceDependency(containerName).setService(
77                     IInventoryService.class).setCallbacks(
78                     "setInventoryService", "unsetInventoryService")
79                     .setRequired(false));
80             c.add(createContainerServiceDependency(containerName).setService(
81                     IStatisticsManager.class).setCallbacks(
82                     "setStatisticsManager", "unsetStatisticsManager")
83                     .setRequired(false));
84             c.add(createContainerServiceDependency(containerName).setService(
85                     ISwitchManagerAware.class).setCallbacks(
86                     "setSwitchManagerAware", "unsetSwitchManagerAware")
87                     .setRequired(false));
88             c.add(createContainerServiceDependency(containerName).setService(
89                     IInventoryListener.class).setCallbacks(
90                     "setInventoryListener", "unsetInventoryListener")
91                     .setRequired(false));
92             c.add(createContainerServiceDependency(containerName).setService(
93                     ISpanAware.class).setCallbacks("setSpanAware",
94                     "unsetSpanAware").setRequired(false));
95             c.add(createContainerServiceDependency(containerName).setService(
96                     IClusterContainerServices.class).setCallbacks(
97                     "setClusterContainerService",
98                     "unsetClusterContainerService").setRequired(true));
99             c.add(createContainerServiceDependency(containerName).setService(
100                     IConfigurationContainerService.class).setCallbacks(
101                     "setConfigurationContainerService",
102                     "unsetConfigurationContainerService").setRequired(true));
103         }
104     }
105
106     @Override
107     protected Object[] getGlobalImplementations() {
108         final Object[] res = { SwitchManagerCLI.class };
109         return res;
110     }
111 }