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