4202856774b81a19403a0de2f193c8aa24bf185e
[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 import org.apache.felix.dm.Component;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
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.INeutronSubnetCRUD;
23 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
24
25 public class Activator extends ComponentActivatorAbstractBase {
26     protected static final Logger logger = LoggerFactory
27     .getLogger(Activator.class);
28
29     /**
30      * Function called when the activator starts just after some
31      * initializations are done by the
32      * ComponentActivatorAbstractBase.
33      *
34      */
35     public void init() {
36
37     }
38
39     /**
40      * Function called when the activator stops just before the
41      * cleanup done by ComponentActivatorAbstractBase
42      *
43      */
44     public void destroy() {
45
46     }
47
48     /**
49      * Function that is used to communicate to dependency manager the
50      * list of known implementations for services inside a container
51      *
52      *
53      * @return An array containing all the CLASS objects that will be
54      * instantiated in order to get an fully working implementation
55      * Object
56      */
57     public Object[] getImplementations() {
58         Object[] res = { NeutronFloatingIPInterface.class,
59                 NeutronRouterInterface.class,
60                 NeutronPortInterface.class,
61                 NeutronSubnetInterface.class,
62                 NeutronNetworkInterface.class };
63         return res;
64     }
65
66     /**
67      * Function that is called when configuration of the dependencies
68      * is required.
69      *
70      * @param c dependency manager Component object, used for
71      * configuring the dependencies exported and imported
72      * @param imp Implementation class that is being configured,
73      * needed as long as the same routine can configure multiple
74      * implementations
75      * @param containerName The containerName being configured, this allow
76      * also optional per-container different behavior if needed, usually
77      * should not be the case though.
78      */
79     public void configureInstance(Component c, Object imp, String containerName) {
80         if (imp.equals(NeutronFloatingIPInterface.class)) {
81             // export the service
82             c.setInterface(
83                     new String[] { INeutronFloatingIPCRUD.class.getName() }, null);
84             Dictionary<String, String> props = new Hashtable<String, String>();
85             props.put("salListenerName", "neutron");
86             c.add(createContainerServiceDependency(containerName)
87                     .setService(IClusterContainerServices.class)
88                     .setCallbacks("setClusterContainerService",
89                     "unsetClusterContainerService").setRequired(true));
90         }
91         if (imp.equals(NeutronRouterInterface.class)) {
92             // export the service
93             c.setInterface(
94                     new String[] { INeutronRouterCRUD.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         }
102         if (imp.equals(NeutronPortInterface.class)) {
103             // export the service
104             c.setInterface(
105                     new String[] { INeutronPortCRUD.class.getName() }, null);
106             Dictionary<String, String> props = new Hashtable<String, String>();
107             props.put("salListenerName", "neutron");
108             c.add(createContainerServiceDependency(containerName)
109                     .setService(IClusterContainerServices.class)
110                     .setCallbacks("setClusterContainerService",
111                     "unsetClusterContainerService").setRequired(true));
112         }
113         if (imp.equals(NeutronSubnetInterface.class)) {
114             // export the service
115             c.setInterface(
116                     new String[] { INeutronSubnetCRUD.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         }
124         if (imp.equals(NeutronNetworkInterface.class)) {
125             // export the service
126             c.setInterface(
127                     new String[] { INeutronNetworkCRUD.class.getName() }, null);
128             Dictionary<String, String> props = new Hashtable<String, String>();
129             props.put("salListenerName", "neutron");
130             c.add(createContainerServiceDependency(containerName)
131                     .setService(IClusterContainerServices.class)
132                     .setCallbacks("setClusterContainerService",
133                     "unsetClusterContainerService").setRequired(true));
134         }
135     }
136 }