Merge "BUG 1839 - HTTP delete of non existing data"
[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.clustering.services.IClusterGlobalServices;
15 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
16 import org.opendaylight.controller.configuration.IConfigurationContainerService;
17 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
18 import org.opendaylight.controller.sal.inventory.IInventoryService;
19 import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates;
20 import org.opendaylight.controller.statisticsmanager.IStatisticsManager;
21 import org.opendaylight.controller.switchmanager.IInventoryListener;
22 import org.opendaylight.controller.switchmanager.ISpanAware;
23 import org.opendaylight.controller.switchmanager.ISwitchManager;
24 import org.opendaylight.controller.switchmanager.ISwitchManagerAware;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27
28 /**
29  * SwitchManager Bundle Activator
30  *
31  *
32  */
33 public class Activator extends ComponentActivatorAbstractBase {
34     protected static final Logger logger = LoggerFactory
35             .getLogger(Activator.class);
36
37
38     /**
39      * Function that is used to communicate to dependency manager the
40      * list of known implementations for services inside a container
41      *
42      *
43      * @return An array containing all the CLASS objects that will be
44      * instantiated in order to get an fully working implementation
45      * Object
46      */
47     @Override
48     public Object[] getImplementations() {
49         Object[] res = { SwitchManager.class };
50         return res;
51     }
52
53     /**
54      * Function that is called when configuration of the dependencies
55      * is required.
56      *
57      * @param c dependency manager Component object, used for
58      * configuring the dependencies exported and imported
59      * @param imp Implementation class that is being configured,
60      * needed as long as the same routine can configure multiple
61      * implementations
62      * @param containerName The containerName being configured, this allow
63      * also optional per-container different behavior if needed, usually
64      * should not be the case though.
65      */
66     @Override
67     public void configureInstance(Component c, Object imp, String containerName) {
68         if (imp.equals(SwitchManager.class)) {
69             // export the service
70             c.setInterface(new String[] {
71                     IListenInventoryUpdates.class.getName(),
72                     ISwitchManager.class.getName(),
73                     IConfigurationContainerAware.class.getName() }, null);
74
75             // Now lets add a service dependency to make sure the
76             // provider of service exists
77             c.add(createContainerServiceDependency(containerName).setService(
78                     IInventoryService.class).setCallbacks(
79                     "setInventoryService", "unsetInventoryService")
80                     .setRequired(true));
81             c.add(createContainerServiceDependency(containerName).setService(
82                     IStatisticsManager.class).setCallbacks(
83                     "setStatisticsManager", "unsetStatisticsManager")
84                     .setRequired(false));
85             c.add(createContainerServiceDependency(containerName).setService(
86                     ISwitchManagerAware.class).setCallbacks(
87                     "setSwitchManagerAware", "unsetSwitchManagerAware")
88                     .setRequired(false));
89             c.add(createContainerServiceDependency(containerName).setService(
90                     IInventoryListener.class).setCallbacks(
91                     "setInventoryListener", "unsetInventoryListener")
92                     .setRequired(false));
93             c.add(createContainerServiceDependency(containerName).setService(
94                     ISpanAware.class).setCallbacks("setSpanAware",
95                     "unsetSpanAware").setRequired(false));
96             c.add(createContainerServiceDependency(containerName).setService(
97                     IClusterContainerServices.class).setCallbacks(
98                     "setClusterContainerService",
99                     "unsetClusterContainerService").setRequired(true));
100             c.add(createContainerServiceDependency(containerName).setService(
101                     IConfigurationContainerService.class).setCallbacks(
102                     "setConfigurationContainerService",
103                     "unsetConfigurationContainerService").setRequired(true));
104             c.add(createServiceDependency()
105                     .setService(IControllerProperties.class)
106                     .setCallbacks("setControllerProperties", "unsetControllerProperties")
107                     .setRequired(true));
108         }
109     }
110
111     /**
112      * {@inheritDoc}
113      */
114     @Override
115     protected Object[] getGlobalImplementations() {
116         final Object[] res = { ControllerProperties.class, SwitchManagerCLI.class };
117         return res;
118     }
119
120     /**
121      * {@inheritDoc}
122      */
123     @Override
124     public void configureGlobalInstance(Component c, Object imp) {
125         if (imp.equals(ControllerProperties.class)) {
126             c.setInterface(new String[] { IControllerProperties.class.getName() }, null);
127
128             c.add(createServiceDependency()
129                     .setService(IClusterGlobalServices.class)
130                     .setCallbacks("setClusterService", "unsetClusterService")
131                     .setRequired(true));
132         }
133     }
134 }