BUG-956 deadlock by rpc invocation - phase2
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / SwitchConnectionHandlerImpl.java
index f571e0094b3a05a0ec8f6b69bbdfde86386529a3..294a75a7caaaea0ac4ec957251a949cec1d8cdf2 100644 (file)
@@ -16,14 +16,12 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.openflowplugin.openflow.md.queue.MessageSpy;
-import org.opendaylight.openflowplugin.openflow.md.queue.MessageSpyCounterImpl;
 import org.opendaylight.openflowplugin.openflow.md.queue.QueueKeeperLightImpl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
 /**
- * @author mirehak
- *
+ * basic interconnecting piece between plugin and library 
  */
 public class SwitchConnectionHandlerImpl implements SwitchConnectionHandler {
     
@@ -38,19 +36,22 @@ public class SwitchConnectionHandlerImpl implements SwitchConnectionHandler {
      *
      */
     public SwitchConnectionHandlerImpl() {
-        messageSpy = new MessageSpyCounterImpl();
         queueKeeper = new QueueKeeperLightImpl();
+        
+        //TODO: implement shutdown invocation upon service stop event
+        spyPool = new ScheduledThreadPoolExecutor(1);
+    }
+
+    /**
+     * wire all up
+     */
+    public void init() {
         queueKeeper.setTranslatorMapping(OFSessionUtil.getTranslatorMap());
         queueKeeper.setPopListenersMapping(OFSessionUtil.getPopListenerMapping());
         queueKeeper.setMessageSpy(messageSpy);
         
         queueKeeper.init();
-
-        errorHandler = new ErrorHandlerQueueImpl();
-        new Thread(errorHandler).start();
         
-        //TODO: implement shutdown invocation upon service stop event
-        spyPool = new ScheduledThreadPoolExecutor(1);
         spyPool.scheduleAtFixedRate(messageSpy, spyRate, spyRate, TimeUnit.SECONDS);
     }
 
@@ -66,5 +67,19 @@ public class SwitchConnectionHandlerImpl implements SwitchConnectionHandler {
                 connectionAdapter, queueKeeper);
         conductor.setErrorHandler(errorHandler);
     }
+    
+    /**
+     * @param messageSpy the messageSpy to set
+     */
+    public void setMessageSpy(MessageSpy<OfHeader, DataObject> messageSpy) {
+        this.messageSpy = messageSpy;
+    }
+    
+    /**
+     * @param errorHandler the errorHandler to set
+     */
+    public void setErrorHandler(ErrorHandler errorHandler) {
+        this.errorHandler = errorHandler;
+    }
 
 }