Merge "BUG-2477 Remove unused pax-exam plugin from netconf-it"
[controller.git] / opendaylight / networkconfiguration / neutron / implementation / src / main / java / org / opendaylight / controller / networkconfig / neutron / implementation / Activator.java
index d8d5cc4a0ab896cd0ca329505f408b591806615e..0fbf933c17f828038183bb32e4f96d6c84bfa6f2 100644 (file)
-/*\r
- * Copyright IBM Corporation, 2013.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-\r
-package org.opendaylight.controller.networkconfig.neutron.implementation;\r
-\r
-import java.util.Hashtable;\r
-import java.util.Dictionary;\r
-import org.apache.felix.dm.Component;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import org.opendaylight.controller.clustering.services.IClusterContainerServices;\r
-import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPCRUD;\r
-import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;\r
-import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;\r
-import org.opendaylight.controller.networkconfig.neutron.INeutronRouterCRUD;\r
-import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;\r
-import org.opendaylight.controller.networkconfig.neutron.implementation.NeutronFloatingIPInterface;\r
-import org.opendaylight.controller.networkconfig.neutron.implementation.NeutronNetworkInterface;\r
-import org.opendaylight.controller.networkconfig.neutron.implementation.NeutronPortInterface;\r
-import org.opendaylight.controller.networkconfig.neutron.implementation.NeutronRouterInterface;\r
-import org.opendaylight.controller.networkconfig.neutron.implementation.NeutronSubnetInterface;\r
-import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;\r
-\r
-public class Activator extends ComponentActivatorAbstractBase {\r
-    protected static final Logger logger = LoggerFactory\r
-    .getLogger(Activator.class);\r
-\r
-    /**\r
-     * Function called when the activator starts just after some\r
-     * initializations are done by the\r
-     * ComponentActivatorAbstractBase.\r
-     *\r
-     */\r
-    public void init() {\r
-\r
-    }\r
-\r
-    /**\r
-     * Function called when the activator stops just before the\r
-     * cleanup done by ComponentActivatorAbstractBase\r
-     *\r
-     */\r
-    public void destroy() {\r
-\r
-    }\r
-\r
-    /**\r
-     * Function that is used to communicate to dependency manager the\r
-     * list of known implementations for services inside a container\r
-     *\r
-     *\r
-     * @return An array containing all the CLASS objects that will be\r
-     * instantiated in order to get an fully working implementation\r
-     * Object\r
-     */\r
-    public Object[] getImplementations() {\r
-        Object[] res = { NeutronFloatingIPInterface.class,\r
-                NeutronRouterInterface.class,\r
-                NeutronPortInterface.class,\r
-                NeutronSubnetInterface.class,\r
-                NeutronNetworkInterface.class };\r
-        return res;\r
-    }\r
-\r
-    /**\r
-     * Function that is called when configuration of the dependencies\r
-     * is required.\r
-     *\r
-     * @param c dependency manager Component object, used for\r
-     * configuring the dependencies exported and imported\r
-     * @param imp Implementation class that is being configured,\r
-     * needed as long as the same routine can configure multiple\r
-     * implementations\r
-     * @param containerName The containerName being configured, this allow\r
-     * also optional per-container different behavior if needed, usually\r
-     * should not be the case though.\r
-     */\r
-    public void configureInstance(Component c, Object imp, String containerName) {\r
-        if (imp.equals(NeutronFloatingIPInterface.class)) {\r
-            // export the service\r
-            c.setInterface(\r
-                    new String[] { INeutronFloatingIPCRUD.class.getName() }, null);\r
-            Dictionary<String, String> props = new Hashtable<String, String>();\r
-            props.put("salListenerName", "neutron");\r
-            c.add(createContainerServiceDependency(containerName)\r
-                    .setService(IClusterContainerServices.class)\r
-                    .setCallbacks("setClusterContainerService",\r
-                    "unsetClusterContainerService").setRequired(true));\r
-        }\r
-        if (imp.equals(NeutronRouterInterface.class)) {\r
-            // export the service\r
-            c.setInterface(\r
-                    new String[] { INeutronRouterCRUD.class.getName() }, null);\r
-            Dictionary<String, String> props = new Hashtable<String, String>();\r
-            props.put("salListenerName", "neutron");\r
-            c.add(createContainerServiceDependency(containerName)\r
-                    .setService(IClusterContainerServices.class)\r
-                    .setCallbacks("setClusterContainerService",\r
-                    "unsetClusterContainerService").setRequired(true));\r
-        }\r
-        if (imp.equals(NeutronPortInterface.class)) {\r
-            // export the service\r
-            c.setInterface(\r
-                    new String[] { INeutronPortCRUD.class.getName() }, null);\r
-            Dictionary<String, String> props = new Hashtable<String, String>();\r
-            props.put("salListenerName", "neutron");\r
-            c.add(createContainerServiceDependency(containerName)\r
-                    .setService(IClusterContainerServices.class)\r
-                    .setCallbacks("setClusterContainerService",\r
-                    "unsetClusterContainerService").setRequired(true));\r
-        }\r
-        if (imp.equals(NeutronSubnetInterface.class)) {\r
-            // export the service\r
-            c.setInterface(\r
-                    new String[] { INeutronSubnetCRUD.class.getName() }, null);\r
-            Dictionary<String, String> props = new Hashtable<String, String>();\r
-            props.put("salListenerName", "neutron");\r
-            c.add(createContainerServiceDependency(containerName)\r
-                    .setService(IClusterContainerServices.class)\r
-                    .setCallbacks("setClusterContainerService",\r
-                    "unsetClusterContainerService").setRequired(true));\r
-        }\r
-        if (imp.equals(NeutronNetworkInterface.class)) {\r
-            // export the service\r
-            c.setInterface(\r
-                    new String[] { INeutronNetworkCRUD.class.getName() }, null);\r
-            Dictionary<String, String> props = new Hashtable<String, String>();\r
-            props.put("salListenerName", "neutron");\r
-            c.add(createContainerServiceDependency(containerName)\r
-                    .setService(IClusterContainerServices.class)\r
-                    .setCallbacks("setClusterContainerService",\r
-                    "unsetClusterContainerService").setRequired(true));\r
-        }\r
-    }\r
-}\r
+/*
+ * Copyright IBM Corporation, 2013.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.networkconfig.neutron.implementation;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallCRUD;
+import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallPolicyCRUD;
+import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallRuleCRUD;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerCRUD;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerHealthMonitorCRUD;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerListenerCRUD;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolCRUD;
+import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolMemberCRUD;
+import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
+import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
+import org.opendaylight.controller.networkconfig.neutron.INeutronRouterCRUD;
+import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityGroupCRUD;
+import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityRuleCRUD;
+import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Activator implements BundleActivator {
+    protected static final Logger logger = LoggerFactory
+    .getLogger(Activator.class);
+    private List<ServiceRegistration<?>> registrations = new ArrayList<ServiceRegistration<?>>();
+
+    @Override
+    public void start(BundleContext context) throws Exception {
+        NeutronRouterInterface neutronRouterInterface = new NeutronRouterInterface();
+        ServiceRegistration<INeutronRouterCRUD> neutronRouterInterfaceRegistration = context.registerService(INeutronRouterCRUD.class, neutronRouterInterface, null);
+        if(neutronRouterInterfaceRegistration != null) {
+            registrations.add(neutronRouterInterfaceRegistration);
+        }
+        NeutronPortInterface neutronPortInterface = new NeutronPortInterface();
+        ServiceRegistration<INeutronPortCRUD> neutronPortInterfaceRegistration = context.registerService(INeutronPortCRUD.class, neutronPortInterface, null);
+        if(neutronPortInterfaceRegistration != null) {
+            registrations.add(neutronPortInterfaceRegistration);
+        }
+
+        NeutronSubnetInterface neutronSubnetInterface = new NeutronSubnetInterface();
+        ServiceRegistration<INeutronSubnetCRUD> neutronSubnetInterfaceRegistration = context.registerService(INeutronSubnetCRUD.class, neutronSubnetInterface, null);
+        if(neutronSubnetInterfaceRegistration != null) {
+            registrations.add(neutronSubnetInterfaceRegistration);
+        }
+
+        NeutronNetworkInterface neutronNetworkInterface = new NeutronNetworkInterface();
+        ServiceRegistration<INeutronNetworkCRUD> neutronNetworkInterfaceRegistration = context.registerService(INeutronNetworkCRUD.class, neutronNetworkInterface, null);
+        if(neutronNetworkInterfaceRegistration != null) {
+            registrations.add(neutronNetworkInterfaceRegistration);
+        }
+
+        NeutronSecurityGroupInterface neutronSecurityGroupInterface = new NeutronSecurityGroupInterface();
+        ServiceRegistration<INeutronSecurityGroupCRUD> neutronSecurityGroupInterfaceRegistration = context.registerService(INeutronSecurityGroupCRUD.class, neutronSecurityGroupInterface, null);
+        if(neutronSecurityGroupInterfaceRegistration != null) {
+            registrations.add(neutronSecurityGroupInterfaceRegistration);
+        }
+
+        NeutronSecurityRuleInterface neutronSecurityRuleInterface = new NeutronSecurityRuleInterface();
+        ServiceRegistration<INeutronSecurityRuleCRUD> neutronSecurityRuleInterfaceRegistration = context.registerService(INeutronSecurityRuleCRUD.class, neutronSecurityRuleInterface, null);
+        if(neutronSecurityRuleInterfaceRegistration != null) {
+            registrations.add(neutronSecurityRuleInterfaceRegistration);
+        }
+
+        NeutronFirewallInterface neutronFirewallInterface = new NeutronFirewallInterface();
+        ServiceRegistration<INeutronFirewallCRUD> neutronFirewallInterfaceRegistration = context.registerService(INeutronFirewallCRUD.class, neutronFirewallInterface, null);
+        if(neutronFirewallInterfaceRegistration != null) {
+            registrations.add(neutronFirewallInterfaceRegistration);
+        }
+
+        NeutronFirewallPolicyInterface neutronFirewallPolicyInterface = new NeutronFirewallPolicyInterface();
+        ServiceRegistration<INeutronFirewallPolicyCRUD> neutronFirewallPolicyInterfaceRegistration = context.registerService(INeutronFirewallPolicyCRUD.class, neutronFirewallPolicyInterface, null);
+        if(neutronFirewallPolicyInterfaceRegistration != null) {
+            registrations.add(neutronFirewallPolicyInterfaceRegistration);
+        }
+
+        NeutronFirewallRuleInterface neutronFirewallRuleInterface = new NeutronFirewallRuleInterface();
+        ServiceRegistration<INeutronFirewallRuleCRUD> neutronFirewallRuleInterfaceRegistration = context.registerService(INeutronFirewallRuleCRUD.class, neutronFirewallRuleInterface, null);
+        if(neutronFirewallRuleInterfaceRegistration != null) {
+            registrations.add(neutronFirewallRuleInterfaceRegistration);
+        }
+
+        NeutronLoadBalancerInterface neutronLoadBalancerInterface = new NeutronLoadBalancerInterface();
+        ServiceRegistration<INeutronLoadBalancerCRUD> neutronLoadBalancerInterfaceRegistration = context.registerService(INeutronLoadBalancerCRUD.class, neutronLoadBalancerInterface, null);
+        if(neutronFirewallInterfaceRegistration != null) {
+            registrations.add(neutronLoadBalancerInterfaceRegistration);
+        }
+
+        NeutronLoadBalancerPoolInterface neutronLoadBalancerPoolInterface = new NeutronLoadBalancerPoolInterface();
+        ServiceRegistration<INeutronLoadBalancerPoolCRUD> neutronLoadBalancerPoolInterfaceRegistration = context.registerService(INeutronLoadBalancerPoolCRUD.class, neutronLoadBalancerPoolInterface, null);
+        if(neutronLoadBalancerPoolInterfaceRegistration != null) {
+            registrations.add(neutronLoadBalancerPoolInterfaceRegistration);
+        }
+
+        NeutronLoadBalancerListenerInterface neutronLoadBalancerListenerInterface = new NeutronLoadBalancerListenerInterface();
+        ServiceRegistration<INeutronLoadBalancerListenerCRUD> neutronLoadBalancerListenerInterfaceRegistration = context.registerService(INeutronLoadBalancerListenerCRUD.class, neutronLoadBalancerListenerInterface, null);
+        if(neutronLoadBalancerListenerInterfaceRegistration != null) {
+            registrations.add(neutronLoadBalancerListenerInterfaceRegistration);
+        }
+
+        NeutronLoadBalancerHealthMonitorInterface neutronLoadBalancerHealthMonitorInterface = new NeutronLoadBalancerHealthMonitorInterface();
+        ServiceRegistration<INeutronLoadBalancerHealthMonitorCRUD> neutronLoadBalancerHealthMonitorInterfaceRegistration = context.registerService(INeutronLoadBalancerHealthMonitorCRUD.class, neutronLoadBalancerHealthMonitorInterface, null);
+        if(neutronLoadBalancerHealthMonitorInterfaceRegistration != null) {
+            registrations.add(neutronLoadBalancerHealthMonitorInterfaceRegistration);
+        }
+
+        NeutronLoadBalancerPoolMemberInterface neutronLoadBalancerPoolMemberInterface = new NeutronLoadBalancerPoolMemberInterface();
+        ServiceRegistration<INeutronLoadBalancerPoolMemberCRUD> neutronLoadBalancerPoolMemberInterfaceRegistration = context.registerService(INeutronLoadBalancerPoolMemberCRUD.class, neutronLoadBalancerPoolMemberInterface, null);
+        if(neutronLoadBalancerPoolMemberInterfaceRegistration != null) {
+            registrations.add(neutronLoadBalancerPoolMemberInterfaceRegistration);
+        }
+
+    }
+
+    @Override
+    public void stop(BundleContext context) throws Exception {
+       for(ServiceRegistration registration : registrations) {
+           if(registration != null) {
+               registration.unregister();
+           }
+       }
+
+    }
+}
\ No newline at end of file