Merge "BUG 1082 Migrate sal-rest-connector to Async Data Broker API"
[controller.git] / opendaylight / networkconfiguration / neutron / implementation / src / main / java / org / opendaylight / controller / networkconfig / neutron / implementation / Activator.java
1 /*
2  * Copyright IBM Corporation, 2013.  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.networkconfig.neutron.implementation;
10
11 import org.apache.felix.dm.Component;
12 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
13 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
14 import org.opendaylight.controller.configuration.IConfigurationContainerService;
15 import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallCRUD;
16 import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallPolicyCRUD;
17 import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallRuleCRUD;
18 import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPCRUD;
19 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
20 import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
21 import org.opendaylight.controller.networkconfig.neutron.INeutronRouterCRUD;
22 import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityGroupCRUD;
23 import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityRuleCRUD;
24 import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
25 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28
29 import java.util.Dictionary;
30 import java.util.Hashtable;
31
32 public class Activator extends ComponentActivatorAbstractBase {
33     protected static final Logger logger = LoggerFactory
34     .getLogger(Activator.class);
35
36     /**
37      * Function called when the activator starts just after some
38      * initializations are done by the
39      * ComponentActivatorAbstractBase.
40      *
41      */
42     @Override
43     public void init() {
44
45     }
46
47     /**
48      * Function called when the activator stops just before the
49      * cleanup done by ComponentActivatorAbstractBase
50      *
51      */
52     @Override
53     public void destroy() {
54
55     }
56
57     /**
58      * Function that is used to communicate to dependency manager the
59      * list of known implementations for services inside a container
60      *
61      *
62      * @return An array containing all the CLASS objects that will be
63      * instantiated in order to get an fully working implementation
64      * Object
65      */
66     @Override
67     public Object[] getImplementations() {
68         Object[] res = { NeutronFloatingIPInterface.class,
69                 NeutronRouterInterface.class,
70                 NeutronPortInterface.class,
71                 NeutronSubnetInterface.class,
72                 NeutronNetworkInterface.class,
73                 NeutronSecurityGroupInterface.class,
74                 NeutronSecurityRuleInterface.class,
75                 NeutronFirewallInterface.class,
76                 NeutronFirewallPolicyInterface.class,
77                 NeutronFirewallRuleInterface.class};
78         return res;
79     }
80
81     /**
82      * Function that is called when configuration of the dependencies
83      * is required.
84      *
85      * @param c dependency manager Component object, used for
86      * configuring the dependencies exported and imported
87      * @param imp Implementation class that is being configured,
88      * needed as long as the same routine can configure multiple
89      * implementations
90      * @param containerName The containerName being configured, this allow
91      * also optional per-container different behavior if needed, usually
92      * should not be the case though.
93      */
94     @Override
95     public void configureInstance(Component c, Object imp, String containerName) {
96         if (imp.equals(NeutronFloatingIPInterface.class)) {
97             // export the service
98             c.setInterface(
99                     new String[] { INeutronFloatingIPCRUD.class.getName(),
100                                    IConfigurationContainerAware.class.getName()}, null);
101             Dictionary<String, String> props = new Hashtable<String, String>();
102             props.put("salListenerName", "neutron");
103             c.add(createContainerServiceDependency(containerName)
104                     .setService(IClusterContainerServices.class)
105                     .setCallbacks("setClusterContainerService",
106                     "unsetClusterContainerService").setRequired(true));
107             c.add(createContainerServiceDependency(containerName).setService(
108                     IConfigurationContainerService.class).setCallbacks(
109                     "setConfigurationContainerService",
110                     "unsetConfigurationContainerService").setRequired(true));
111         }
112         if (imp.equals(NeutronRouterInterface.class)) {
113             // export the service
114             c.setInterface(
115                     new String[] { INeutronRouterCRUD.class.getName(),
116                                    IConfigurationContainerAware.class.getName()}, null);
117             Dictionary<String, String> props = new Hashtable<String, String>();
118             props.put("salListenerName", "neutron");
119             c.add(createContainerServiceDependency(containerName)
120                     .setService(IClusterContainerServices.class)
121                     .setCallbacks("setClusterContainerService",
122                     "unsetClusterContainerService").setRequired(true));
123             c.add(createContainerServiceDependency(containerName).setService(
124                     IConfigurationContainerService.class).setCallbacks(
125                     "setConfigurationContainerService",
126                     "unsetConfigurationContainerService").setRequired(true));
127         }
128         if (imp.equals(NeutronPortInterface.class)) {
129             // export the service
130             c.setInterface(
131                     new String[] { INeutronPortCRUD.class.getName(),
132                                    IConfigurationContainerAware.class.getName()}, null);
133             Dictionary<String, String> props = new Hashtable<String, String>();
134             props.put("salListenerName", "neutron");
135             c.add(createContainerServiceDependency(containerName)
136                     .setService(IClusterContainerServices.class)
137                     .setCallbacks("setClusterContainerService",
138                     "unsetClusterContainerService").setRequired(true));
139             c.add(createContainerServiceDependency(containerName).setService(
140                     IConfigurationContainerService.class).setCallbacks(
141                     "setConfigurationContainerService",
142                     "unsetConfigurationContainerService").setRequired(true));
143         }
144         if (imp.equals(NeutronSubnetInterface.class)) {
145             // export the service
146             c.setInterface(
147                     new String[] { INeutronSubnetCRUD.class.getName(),
148                                    IConfigurationContainerAware.class.getName()}, null);
149             Dictionary<String, String> props = new Hashtable<String, String>();
150             props.put("salListenerName", "neutron");
151             c.add(createContainerServiceDependency(containerName)
152                     .setService(IClusterContainerServices.class)
153                     .setCallbacks("setClusterContainerService",
154                     "unsetClusterContainerService").setRequired(true));
155             c.add(createContainerServiceDependency(containerName).setService(
156                     IConfigurationContainerService.class).setCallbacks(
157                     "setConfigurationContainerService",
158                     "unsetConfigurationContainerService").setRequired(true));
159         }
160         if (imp.equals(NeutronNetworkInterface.class)) {
161             // export the service
162             c.setInterface(
163                     new String[] { INeutronNetworkCRUD.class.getName(),
164                                    IConfigurationContainerAware.class.getName()}, null);
165             Dictionary<String, String> props = new Hashtable<String, String>();
166             props.put("salListenerName", "neutron");
167             c.add(createContainerServiceDependency(containerName)
168                     .setService(IClusterContainerServices.class)
169                     .setCallbacks("setClusterContainerService",
170                     "unsetClusterContainerService").setRequired(true));
171             c.add(createContainerServiceDependency(containerName).setService(
172                     IConfigurationContainerService.class).setCallbacks(
173                     "setConfigurationContainerService",
174                     "unsetConfigurationContainerService").setRequired(true));
175         }
176         if (imp.equals(NeutronSecurityGroupInterface.class)) {
177             // export the service
178             c.setInterface(
179                 new String[] { INeutronSecurityGroupCRUD.class.getName(),
180                     IConfigurationContainerAware.class.getName()}, null);
181             Dictionary<String, String> props = new Hashtable<String, String>();
182             props.put("salListenerName", "neutron");
183             c.add(createContainerServiceDependency(containerName)
184                 .setService(IClusterContainerServices.class)
185                 .setCallbacks("setClusterContainerService",
186                     "unsetClusterContainerService").setRequired(true));
187             c.add(createContainerServiceDependency(containerName).setService(
188                 IConfigurationContainerService.class).setCallbacks(
189                 "setConfigurationContainerService",
190                 "unsetConfigurationContainerService").setRequired(true));
191         }
192         if (imp.equals(NeutronSecurityRuleInterface.class)) {
193             // export the service
194             c.setInterface(
195                 new String[] { INeutronSecurityRuleCRUD.class.getName(),
196                     IConfigurationContainerAware.class.getName()}, null);
197             Dictionary<String, String> props = new Hashtable<String, String>();
198             props.put("salListenerName", "neutron");
199             c.add(createContainerServiceDependency(containerName)
200                 .setService(IClusterContainerServices.class)
201                 .setCallbacks("setClusterContainerService",
202                     "unsetClusterContainerService").setRequired(true));
203             c.add(createContainerServiceDependency(containerName).setService(
204                 IConfigurationContainerService.class).setCallbacks(
205                 "setConfigurationContainerService",
206                 "unsetConfigurationContainerService").setRequired(true));
207         }
208         if (imp.equals(NeutronFirewallInterface.class)) {
209             // export the service
210             c.setInterface(
211                     new String[] { INeutronFirewallCRUD.class.getName(),
212                             IConfigurationContainerAware.class.getName()}, null);
213             Dictionary<String, String> props = new Hashtable<String, String>();
214             props.put("salListenerName", "neutron");
215             c.add(createContainerServiceDependency(containerName)
216                     .setService(IClusterContainerServices.class)
217                     .setCallbacks("setClusterContainerService",
218                             "unsetClusterContainerService").setRequired(true));
219             c.add(createContainerServiceDependency(containerName).setService(
220                     IConfigurationContainerService.class).setCallbacks(
221                     "setConfigurationContainerService",
222                     "unsetConfigurationContainerService").setRequired(true));
223         }
224         if (imp.equals(NeutronFirewallPolicyInterface.class)) {
225             // export the service
226             c.setInterface(
227                     new String[] { INeutronFirewallPolicyCRUD.class.getName(),
228                             IConfigurationContainerAware.class.getName()}, null);
229             Dictionary<String, String> props = new Hashtable<String, String>();
230             props.put("salListenerName", "neutron");
231             c.add(createContainerServiceDependency(containerName)
232                     .setService(IClusterContainerServices.class)
233                     .setCallbacks("setClusterContainerService",
234                             "unsetClusterContainerService").setRequired(true));
235             c.add(createContainerServiceDependency(containerName).setService(
236                     IConfigurationContainerService.class).setCallbacks(
237                     "setConfigurationContainerService",
238                     "unsetConfigurationContainerService").setRequired(true));
239         }
240         if (imp.equals(NeutronFirewallRuleInterface.class)) {
241             // export the service
242             c.setInterface(
243                     new String[] { INeutronFirewallRuleCRUD.class.getName(),
244                             IConfigurationContainerAware.class.getName()}, null);
245             Dictionary<String, String> props = new Hashtable<String, String>();
246             props.put("salListenerName", "neutron");
247             c.add(createContainerServiceDependency(containerName)
248                     .setService(IClusterContainerServices.class)
249                     .setCallbacks("setClusterContainerService",
250                             "unsetClusterContainerService").setRequired(true));
251             c.add(createContainerServiceDependency(containerName).setService(
252                     IConfigurationContainerService.class).setCallbacks(
253                     "setConfigurationContainerService",
254                     "unsetConfigurationContainerService").setRequired(true));
255         }
256     }
257 }