2 * Copyright IBM Corporation, 2013. All rights reserved.
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
9 package org.opendaylight.controller.networkconfig.neutron.implementation;
11 import java.util.Hashtable;
12 import java.util.Dictionary;
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.sal.core.ComponentActivatorAbstractBase;
27 public class Activator extends ComponentActivatorAbstractBase {
28 protected static final Logger logger = LoggerFactory
29 .getLogger(Activator.class);
32 * Function called when the activator starts just after some
33 * initializations are done by the
34 * ComponentActivatorAbstractBase.
43 * Function called when the activator stops just before the
44 * cleanup done by ComponentActivatorAbstractBase
48 public void destroy() {
53 * Function that is used to communicate to dependency manager the
54 * list of known implementations for services inside a container
57 * @return An array containing all the CLASS objects that will be
58 * instantiated in order to get an fully working implementation
62 public Object[] getImplementations() {
63 Object[] res = { NeutronFloatingIPInterface.class,
64 NeutronRouterInterface.class,
65 NeutronPortInterface.class,
66 NeutronSubnetInterface.class,
67 NeutronNetworkInterface.class };
72 * Function that is called when configuration of the dependencies
75 * @param c dependency manager Component object, used for
76 * configuring the dependencies exported and imported
77 * @param imp Implementation class that is being configured,
78 * needed as long as the same routine can configure multiple
80 * @param containerName The containerName being configured, this allow
81 * also optional per-container different behavior if needed, usually
82 * should not be the case though.
85 public void configureInstance(Component c, Object imp, String containerName) {
86 if (imp.equals(NeutronFloatingIPInterface.class)) {
89 new String[] { INeutronFloatingIPCRUD.class.getName(),
90 IConfigurationContainerAware.class.getName()}, null);
91 Dictionary<String, String> props = new Hashtable<String, String>();
92 props.put("salListenerName", "neutron");
93 c.add(createContainerServiceDependency(containerName)
94 .setService(IClusterContainerServices.class)
95 .setCallbacks("setClusterContainerService",
96 "unsetClusterContainerService").setRequired(true));
97 c.add(createContainerServiceDependency(containerName).setService(
98 IConfigurationContainerService.class).setCallbacks(
99 "setConfigurationContainerService",
100 "unsetConfigurationContainerService").setRequired(true));
102 if (imp.equals(NeutronRouterInterface.class)) {
103 // export the service
105 new String[] { INeutronRouterCRUD.class.getName(),
106 IConfigurationContainerAware.class.getName()}, null);
107 Dictionary<String, String> props = new Hashtable<String, String>();
108 props.put("salListenerName", "neutron");
109 c.add(createContainerServiceDependency(containerName)
110 .setService(IClusterContainerServices.class)
111 .setCallbacks("setClusterContainerService",
112 "unsetClusterContainerService").setRequired(true));
113 c.add(createContainerServiceDependency(containerName).setService(
114 IConfigurationContainerService.class).setCallbacks(
115 "setConfigurationContainerService",
116 "unsetConfigurationContainerService").setRequired(true));
118 if (imp.equals(NeutronPortInterface.class)) {
119 // export the service
121 new String[] { INeutronPortCRUD.class.getName(),
122 IConfigurationContainerAware.class.getName()}, null);
123 Dictionary<String, String> props = new Hashtable<String, String>();
124 props.put("salListenerName", "neutron");
125 c.add(createContainerServiceDependency(containerName)
126 .setService(IClusterContainerServices.class)
127 .setCallbacks("setClusterContainerService",
128 "unsetClusterContainerService").setRequired(true));
129 c.add(createContainerServiceDependency(containerName).setService(
130 IConfigurationContainerService.class).setCallbacks(
131 "setConfigurationContainerService",
132 "unsetConfigurationContainerService").setRequired(true));
134 if (imp.equals(NeutronSubnetInterface.class)) {
135 // export the service
137 new String[] { INeutronSubnetCRUD.class.getName(),
138 IConfigurationContainerAware.class.getName()}, null);
139 Dictionary<String, String> props = new Hashtable<String, String>();
140 props.put("salListenerName", "neutron");
141 c.add(createContainerServiceDependency(containerName)
142 .setService(IClusterContainerServices.class)
143 .setCallbacks("setClusterContainerService",
144 "unsetClusterContainerService").setRequired(true));
145 c.add(createContainerServiceDependency(containerName).setService(
146 IConfigurationContainerService.class).setCallbacks(
147 "setConfigurationContainerService",
148 "unsetConfigurationContainerService").setRequired(true));
150 if (imp.equals(NeutronNetworkInterface.class)) {
151 // export the service
153 new String[] { INeutronNetworkCRUD.class.getName(),
154 IConfigurationContainerAware.class.getName()}, null);
155 Dictionary<String, String> props = new Hashtable<String, String>();
156 props.put("salListenerName", "neutron");
157 c.add(createContainerServiceDependency(containerName)
158 .setService(IClusterContainerServices.class)
159 .setCallbacks("setClusterContainerService",
160 "unsetClusterContainerService").setRequired(true));
161 c.add(createContainerServiceDependency(containerName).setService(
162 IConfigurationContainerService.class).setCallbacks(
163 "setConfigurationContainerService",
164 "unsetConfigurationContainerService").setRequired(true));