Fix license header violations in net-virt
[ovsdb.git] / openstack / net-virt / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / RouterHandler.java
index 4cd01bbe93c05ae2e7eaa9fadce0d9993ddec2e7..31a7ddb54dbaffbc33dec7a1a8169e4da7ed4571 100644 (file)
@@ -1,35 +1,32 @@
 /*
- * Copyright (C) 2014 Red Hat, Inc.
+ * Copyright (c) 2014, 2015 Red Hat, Inc. and others. 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
- *
- * Authors : Dave Tucker, Flavio Fernandes
  */
+
 package org.opendaylight.ovsdb.openstack.netvirt;
 
+import java.net.HttpURLConnection;
+
 import org.opendaylight.neutron.spi.INeutronRouterAware;
 import org.opendaylight.neutron.spi.NeutronRouter;
 import org.opendaylight.neutron.spi.NeutronRouter_Interface;
 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;
 
-import java.net.HttpURLConnection;
-
 /**
  * Handle requests for Neutron Router.
  */
-public class RouterHandler extends AbstractHandler
-        implements INeutronRouterAware {
-
-    /**
-     * Logger instance.
-     */
-    static final Logger logger = LoggerFactory.getLogger(RouterHandler.class);
+public class RouterHandler extends AbstractHandler implements INeutronRouterAware, ConfigInterface {
+    private static final Logger LOG = LoggerFactory.getLogger(RouterHandler.class);
 
     // The implementation for each of these services is resolved by the OSGi Service Manager
     private volatile NeutronL3Adapter neutronL3Adapter;
@@ -130,7 +127,7 @@ public class RouterHandler extends AbstractHandler
      */
     @Override
     public int canAttachInterface(NeutronRouter router, NeutronRouter_Interface routerInterface) {
-        logger.debug(" Router {} asked if it can attach interface {}. Subnet {}",
+        LOG.debug(" Router {} asked if it can attach interface {}. Subnet {}",
                      router.getName(),
                      routerInterface.getPortUUID(),
                      routerInterface.getSubnetUUID());
@@ -165,7 +162,7 @@ public class RouterHandler extends AbstractHandler
      */
     @Override
     public int canDetachInterface(NeutronRouter router, NeutronRouter_Interface routerInterface) {
-        logger.debug(" Router {} asked if it can detach interface {}. Subnet {}",
+        LOG.debug(" Router {} asked if it can detach interface {}. Subnet {}",
                      router.getName(),
                      routerInterface.getPortUUID(),
                      routerInterface.getSubnetUUID());
@@ -195,7 +192,7 @@ public class RouterHandler extends AbstractHandler
     @Override
     public void processEvent(AbstractEvent abstractEvent) {
         if (!(abstractEvent instanceof NorthboundEvent)) {
-            logger.error("Unable to process abstract event " + abstractEvent);
+            LOG.error("Unable to process abstract event {}", abstractEvent);
             return;
         }
         NorthboundEvent ev = (NorthboundEvent) abstractEvent;
@@ -214,8 +211,21 @@ public class RouterHandler extends AbstractHandler
                 }
                 break;
             default:
-                logger.warn("Unable to process event action " + ev.getAction());
+                LOG.warn("Unable to process event action {}", ev.getAction());
                 break;
         }
     }
+
+    @Override
+    public void setDependencies(BundleContext bundleContext, ServiceReference serviceReference) {
+        neutronL3Adapter =
+                (NeutronL3Adapter) ServiceHelper.getGlobalInstance(NeutronL3Adapter.class, this);
+        eventDispatcher =
+                (EventDispatcher) ServiceHelper.getGlobalInstance(EventDispatcher.class, this);
+        eventDispatcher.eventHandlerAdded(
+                bundleContext.getServiceReference(INeutronRouterAware.class.getName()), this);
+    }
+
+    @Override
+    public void setDependencies(Object impl) {}
 }