add lib-plugin interaction implementations on library side
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / core / PublishingChannelInitializer.java
index 0cf8a5bd6f54978d3831616eedec653fbf1bcec7..5f339fda0868cc41c5735c52d5742d9742057151 100644 (file)
@@ -3,18 +3,22 @@ package org.opendaylight.openflowjava.protocol.impl.core;
 import io.netty.channel.Channel;\r
 import io.netty.channel.ChannelInitializer;\r
 import io.netty.channel.group.DefaultChannelGroup;\r
+import io.netty.channel.socket.SocketChannel;\r
 \r
 import java.util.Iterator;\r
 \r
+import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;\r
+import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler.COMPONENT_NAMES;\r
 \r
 /**\r
  * @author michal.polkorab\r
  *\r
  */\r
-public class PublishingChannelInitializer extends ChannelInitializer<Channel> {\r
+public class PublishingChannelInitializer extends ChannelInitializer<SocketChannel> {\r
 \r
     private DefaultChannelGroup allChannels;\r
+    private SwitchConnectionHandler switchConnectionHandler;\r
     \r
     /**\r
      * default ctor\r
@@ -24,9 +28,15 @@ public class PublishingChannelInitializer extends ChannelInitializer<Channel> {
     }\r
     \r
     @Override\r
-    protected void initChannel(Channel ch) throws Exception {\r
+    protected void initChannel(SocketChannel ch) throws Exception {\r
         allChannels.add(ch);\r
+        //TODO - create inBoundHandler\r
+        if (switchConnectionHandler != null) {\r
+            switchConnectionHandler.onSwitchConnected(ConnectionAdapterFactory.createConnectionAdapter(ch));\r
+            //TODO - check OpenflowProtocolListener, set it to inBoundHandler\r
+        }\r
         ch.pipeline().addLast(COMPONENT_NAMES.TLS_DETECTOR.name(), new TlsDetector());\r
+        //TODO - chain inBoundHandler to pipe\r
     }\r
     \r
     /**\r
@@ -43,6 +53,10 @@ public class PublishingChannelInitializer extends ChannelInitializer<Channel> {
         return allChannels.size();\r
     }\r
     \r
-    \r
-\r
+    /**\r
+     * @param switchListener the switchListener to set\r
+     */\r
+    public void setSwitchConnectionHandler(SwitchConnectionHandler switchListener) {\r
+        this.switchConnectionHandler = switchListener;\r
+    }\r
 }\r