Generify Managers 02/40102/7
authorJozef Bacigal <jbacigal@cisco.com>
Thu, 9 Jun 2016 10:39:21 +0000 (12:39 +0200)
committerJozef Bacigal <jbacigal@cisco.com>
Fri, 17 Jun 2016 11:32:56 +0000 (13:32 +0200)
-gainContex for each manager

Change-Id: Ifa4a60e8a529bbf194a82a0d7622faa9bbb427ec
Signed-off-by: Jozef Bacigal <jbacigal@cisco.com>
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OFPManager.java [new file with mode: 0644]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceManager.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/role/RoleManager.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/rpc/RpcManager.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/statistics/StatisticsManager.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java

diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OFPManager.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OFPManager.java
new file mode 100644 (file)
index 0000000..cf650b1
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, 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
+ */
+package org.opendaylight.openflowplugin.api.openflow;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
+
+/**
+ * Generic API for all managers
+ */
+public interface OFPManager {
+
+    <T extends OFPContext> T gainContext(final DeviceInfo deviceInfo);
+    
+}
index 0e199c26f8adb591e564a9982342c4241b72d6ba..4e4d1d11eb10cc386c0db5bf71aa37d78fd56802 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.openflowplugin.api.openflow.device;
 
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.openflowplugin.api.openflow.OFPManager;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceConnectedHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
@@ -23,7 +24,7 @@ import org.opendaylight.openflowplugin.api.openflow.translator.TranslatorLibrari
  * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 25.2.2015.
  */
 public interface DeviceManager extends DeviceConnectedHandler, DeviceDisconnectedHandler, DeviceLifecycleSupervisor,
-        DeviceInitializationPhaseHandler, DeviceTerminationPhaseHandler, TranslatorLibrarian, AutoCloseable {
+        DeviceInitializationPhaseHandler, DeviceTerminationPhaseHandler, TranslatorLibrarian, AutoCloseable, OFPManager {
 
     /**
      * Sets notification publish service
index dee6ec896a289cc605205ef69c079caf16d23261..bc851df3b64418560240a4003d06ccb90a541377 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.openflowplugin.api.openflow.role;
 
+import org.opendaylight.openflowplugin.api.openflow.OFPManager;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceLifecycleSupervisor;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
@@ -16,7 +17,7 @@ import org.opendaylight.openflowplugin.api.openflow.lifecycle.RoleChangeListener
  * Created by kramesha on 8/31/15.
  */
 public interface RoleManager extends DeviceLifecycleSupervisor, DeviceInitializationPhaseHandler, AutoCloseable,
-        DeviceTerminationPhaseHandler {
+        DeviceTerminationPhaseHandler, OFPManager {
     String ENTITY_TYPE = "openflow";
     String TX_ENTITY_TYPE = "ofTransaction";
 
index 18cffcb69677e2605fba313c3178d1def7527bf4..8952240320db5dfcf9fac262e0c7b2121d773d6e 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.api.openflow.rpc;
 
+import org.opendaylight.openflowplugin.api.openflow.OFPManager;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceLifecycleSupervisor;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
@@ -20,6 +21,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
  * <p>
  * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 25.2.2015.
  */
-public interface RpcManager extends DeviceLifecycleSupervisor, DeviceInitializationPhaseHandler, AutoCloseable, DeviceTerminationPhaseHandler {
+public interface RpcManager extends DeviceLifecycleSupervisor, DeviceInitializationPhaseHandler, AutoCloseable, DeviceTerminationPhaseHandler, OFPManager {
 
 }
index 246114a14946d3d7c48647dc2e85eca5c2e3ce90..0be663ce7ea74257414bb23f7ad9bd36cb56cd50 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.api.openflow.statistics;
 
+import org.opendaylight.openflowplugin.api.openflow.OFPManager;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
@@ -18,7 +19,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
  * Manager to start or stop scheduling statistics
  */
 public interface StatisticsManager extends DeviceLifecycleSupervisor, DeviceInitializationPhaseHandler,
-        DeviceTerminationPhaseHandler, AutoCloseable {
+        DeviceTerminationPhaseHandler, AutoCloseable, OFPManager {
 
     void startScheduling(DeviceInfo deviceInfo);
     void stopScheduling(DeviceInfo deviceInfo);
index 988007a475b430f0eeede494ca1b0e3c9ee4e7ad..2eb7884989da497dbd1fb59e0deeb1ccb5578157 100644 (file)
@@ -30,6 +30,7 @@ import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
+import org.opendaylight.openflowplugin.api.openflow.OFPContext;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProvider;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
@@ -311,4 +312,9 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     void addDeviceContextToMap(final DeviceInfo deviceInfo, final DeviceContext deviceContext){
         deviceContexts.put(deviceInfo, deviceContext);
     }
+
+    @Override
+    public <T extends OFPContext> T gainContext(final DeviceInfo deviceInfo) {
+        return (T) deviceContexts.get(deviceInfo);
+    }
 }
index 5a74eed9bee0b5462abb531012f2cb802ddc494c..f6380de5d7e9ed5b0487aeddfa798247b42cb9bf 100644 (file)
@@ -39,6 +39,7 @@ import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipS
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.OFPContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
@@ -400,4 +401,8 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
         }
     }
 
+    @Override
+    public <T extends OFPContext> T gainContext(DeviceInfo deviceInfo) {
+        return (T) contexts.get(deviceInfo);
+    }
 }
index bab33a358fb162f9cfc314f81f745e6d8bbcab2a..8857ed9e067f91e0eaf86daa9eb43674459e3a8f 100644 (file)
@@ -15,6 +15,7 @@ import java.util.Iterator;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.openflowplugin.api.openflow.OFPContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
@@ -101,4 +102,9 @@ public class RpcManagerImpl implements RpcManager {
             this.contexts.put(deviceInfo,rpcContexts);
         }
     }
+
+    @Override
+    public <T extends OFPContext> T gainContext(DeviceInfo deviceInfo) {
+        return (T) contexts.get(deviceInfo);
+    }
 }
index 9d2df471c08311e2334c561ae047c621dfd7b1c2..be26b7a4dd95050a9cebe069ea57cfa6a8cb9684 100644 (file)
@@ -20,6 +20,7 @@ import io.netty.util.Timeout;
 import io.netty.util.TimerTask;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.openflowplugin.api.openflow.OFPContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
@@ -312,4 +313,9 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
     public void setDeviceTerminationPhaseHandler(final DeviceTerminationPhaseHandler handler) {
         this.deviceTerminPhaseHandler = handler;
     }
+
+    @Override
+    public <T extends OFPContext> T gainContext(DeviceInfo deviceInfo) {
+        return (T) contexts.get(deviceInfo);
+    }
 }