Merge "Remove unused spring dependency and wrong version in web pom"
[controller.git] / opendaylight / networkconfiguration / neutron / implementation / src / main / java / org / opendaylight / controller / networkconfig / neutron / implementation / Activator.java
1 /*\r
2  * Copyright IBM Corporation, 2013.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 package org.opendaylight.controller.networkconfig.neutron.implementation;\r
10 \r
11 import java.util.Hashtable;\r
12 import java.util.Dictionary;\r
13 import org.apache.felix.dm.Component;\r
14 import org.slf4j.Logger;\r
15 import org.slf4j.LoggerFactory;\r
16 \r
17 import org.opendaylight.controller.clustering.services.IClusterContainerServices;\r
18 import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPCRUD;\r
19 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;\r
20 import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;\r
21 import org.opendaylight.controller.networkconfig.neutron.INeutronRouterCRUD;\r
22 import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;\r
23 import org.opendaylight.controller.networkconfig.neutron.implementation.NeutronFloatingIPInterface;\r
24 import org.opendaylight.controller.networkconfig.neutron.implementation.NeutronNetworkInterface;\r
25 import org.opendaylight.controller.networkconfig.neutron.implementation.NeutronPortInterface;\r
26 import org.opendaylight.controller.networkconfig.neutron.implementation.NeutronRouterInterface;\r
27 import org.opendaylight.controller.networkconfig.neutron.implementation.NeutronSubnetInterface;\r
28 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;\r
29 \r
30 public class Activator extends ComponentActivatorAbstractBase {\r
31     protected static final Logger logger = LoggerFactory\r
32     .getLogger(Activator.class);\r
33 \r
34     /**\r
35      * Function called when the activator starts just after some\r
36      * initializations are done by the\r
37      * ComponentActivatorAbstractBase.\r
38      *\r
39      */\r
40     public void init() {\r
41 \r
42     }\r
43 \r
44     /**\r
45      * Function called when the activator stops just before the\r
46      * cleanup done by ComponentActivatorAbstractBase\r
47      *\r
48      */\r
49     public void destroy() {\r
50 \r
51     }\r
52 \r
53     /**\r
54      * Function that is used to communicate to dependency manager the\r
55      * list of known implementations for services inside a container\r
56      *\r
57      *\r
58      * @return An array containing all the CLASS objects that will be\r
59      * instantiated in order to get an fully working implementation\r
60      * Object\r
61      */\r
62     public Object[] getImplementations() {\r
63         Object[] res = { NeutronFloatingIPInterface.class,\r
64                 NeutronRouterInterface.class,\r
65                 NeutronPortInterface.class,\r
66                 NeutronSubnetInterface.class,\r
67                 NeutronNetworkInterface.class };\r
68         return res;\r
69     }\r
70 \r
71     /**\r
72      * Function that is called when configuration of the dependencies\r
73      * is required.\r
74      *\r
75      * @param c dependency manager Component object, used for\r
76      * configuring the dependencies exported and imported\r
77      * @param imp Implementation class that is being configured,\r
78      * needed as long as the same routine can configure multiple\r
79      * implementations\r
80      * @param containerName The containerName being configured, this allow\r
81      * also optional per-container different behavior if needed, usually\r
82      * should not be the case though.\r
83      */\r
84     public void configureInstance(Component c, Object imp, String containerName) {\r
85         if (imp.equals(NeutronFloatingIPInterface.class)) {\r
86             // export the service\r
87             c.setInterface(\r
88                     new String[] { INeutronFloatingIPCRUD.class.getName() }, null);\r
89             Dictionary<String, String> props = new Hashtable<String, String>();\r
90             props.put("salListenerName", "neutron");\r
91             c.add(createContainerServiceDependency(containerName)\r
92                     .setService(IClusterContainerServices.class)\r
93                     .setCallbacks("setClusterContainerService",\r
94                     "unsetClusterContainerService").setRequired(true));\r
95         }\r
96         if (imp.equals(NeutronRouterInterface.class)) {\r
97             // export the service\r
98             c.setInterface(\r
99                     new String[] { INeutronRouterCRUD.class.getName() }, null);\r
100             Dictionary<String, String> props = new Hashtable<String, String>();\r
101             props.put("salListenerName", "neutron");\r
102             c.add(createContainerServiceDependency(containerName)\r
103                     .setService(IClusterContainerServices.class)\r
104                     .setCallbacks("setClusterContainerService",\r
105                     "unsetClusterContainerService").setRequired(true));\r
106         }\r
107         if (imp.equals(NeutronPortInterface.class)) {\r
108             // export the service\r
109             c.setInterface(\r
110                     new String[] { INeutronPortCRUD.class.getName() }, null);\r
111             Dictionary<String, String> props = new Hashtable<String, String>();\r
112             props.put("salListenerName", "neutron");\r
113             c.add(createContainerServiceDependency(containerName)\r
114                     .setService(IClusterContainerServices.class)\r
115                     .setCallbacks("setClusterContainerService",\r
116                     "unsetClusterContainerService").setRequired(true));\r
117         }\r
118         if (imp.equals(NeutronSubnetInterface.class)) {\r
119             // export the service\r
120             c.setInterface(\r
121                     new String[] { INeutronSubnetCRUD.class.getName() }, null);\r
122             Dictionary<String, String> props = new Hashtable<String, String>();\r
123             props.put("salListenerName", "neutron");\r
124             c.add(createContainerServiceDependency(containerName)\r
125                     .setService(IClusterContainerServices.class)\r
126                     .setCallbacks("setClusterContainerService",\r
127                     "unsetClusterContainerService").setRequired(true));\r
128         }\r
129         if (imp.equals(NeutronNetworkInterface.class)) {\r
130             // export the service\r
131             c.setInterface(\r
132                     new String[] { INeutronNetworkCRUD.class.getName() }, null);\r
133             Dictionary<String, String> props = new Hashtable<String, String>();\r
134             props.put("salListenerName", "neutron");\r
135             c.add(createContainerServiceDependency(containerName)\r
136                     .setService(IClusterContainerServices.class)\r
137                     .setCallbacks("setClusterContainerService",\r
138                     "unsetClusterContainerService").setRequired(true));\r
139         }\r
140     }\r
141 }\r