Use config instead of Activator for netvirt and netvirt-providers
[ovsdb.git] / openstack / net-virt / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / FloatingIPHandler.java
index 581aba4d4c82ad5425a1f7524a3b35391b70e1cf..cda629dc7f524667571e0d361e76198d5d9fb859 100644 (file)
@@ -9,10 +9,15 @@
  */
 package org.opendaylight.ovsdb.openstack.netvirt;
 
-import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPAware;
-import org.opendaylight.controller.networkconfig.neutron.NeutronFloatingIP;
+import org.opendaylight.neutron.spi.INeutronFloatingIPAware;
+import org.opendaylight.neutron.spi.NeutronFloatingIP;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
+import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
 import org.opendaylight.ovsdb.openstack.netvirt.impl.NeutronL3Adapter;
 
+import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -22,15 +27,13 @@ import java.net.HttpURLConnection;
  * Handle requests for Neutron Floating IP.
  */
 public class FloatingIPHandler extends AbstractHandler
-        implements INeutronFloatingIPAware {
+        implements INeutronFloatingIPAware, ConfigInterface {
 
-    /**
-     * Logger instance.
-     */
     static final Logger logger = LoggerFactory.getLogger(FloatingIPHandler.class);
 
     // The implementation for each of these services is resolved by the OSGi Service Manager
     private volatile NeutronL3Adapter neutronL3Adapter;
+    private volatile EventDispatcher eventDispatcher;
 
     /**
      * Services provide this interface method to indicate if the specified floatingIP can be created
@@ -56,7 +59,7 @@ public class FloatingIPHandler extends AbstractHandler
      */
     @Override
     public void neutronFloatingIPCreated(NeutronFloatingIP floatingIP) {
-        enqueueEvent(new NorthboundEvent(floatingIP, AbstractEvent.Action.ADD));
+        enqueueEvent(new NorthboundEvent(floatingIP, Action.ADD));
     }
 
     /**
@@ -85,7 +88,7 @@ public class FloatingIPHandler extends AbstractHandler
      */
     @Override
     public void neutronFloatingIPUpdated(NeutronFloatingIP floatingIP) {
-        enqueueEvent(new NorthboundEvent(floatingIP, AbstractEvent.Action.UPDATE));
+        enqueueEvent(new NorthboundEvent(floatingIP, Action.UPDATE));
     }
 
     /**
@@ -111,14 +114,14 @@ public class FloatingIPHandler extends AbstractHandler
      */
     @Override
     public void neutronFloatingIPDeleted(NeutronFloatingIP floatingIP) {
-        enqueueEvent(new NorthboundEvent(floatingIP, AbstractEvent.Action.DELETE));
+        enqueueEvent(new NorthboundEvent(floatingIP, Action.DELETE));
     }
 
     /**
      * Process the event.
      *
      * @param abstractEvent the {@link org.opendaylight.ovsdb.openstack.netvirt.AbstractEvent} event to be handled.
-     * @see EventDispatcher
+     * @see org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher
      */
     @Override
     public void processEvent(AbstractEvent abstractEvent) {
@@ -140,4 +143,18 @@ public class FloatingIPHandler extends AbstractHandler
                 break;
         }
     }
+
+    @Override
+    public void setDependencies(BundleContext bundleContext, ServiceReference serviceReference) {
+        eventDispatcher =
+                (EventDispatcher) ServiceHelper.getGlobalInstance(EventDispatcher.class, this);
+        eventDispatcher.eventHandlerAdded(
+                bundleContext.getServiceReference(INeutronFloatingIPAware.class.getName()), this);
+        super.setDispatcher(eventDispatcher);
+        neutronL3Adapter =
+                (NeutronL3Adapter) ServiceHelper.getGlobalInstance(NeutronL3Adapter.class, this);
+    }
+
+    @Override
+    public void setDependencies(Object impl) {}
 }