BUG-634: improve netty interface 36/6536/2
authorRobert Varga <rovarga@cisco.com>
Sun, 27 Apr 2014 09:54:36 +0000 (11:54 +0200)
committerRobert Varga <rovarga@cisco.com>
Mon, 28 Apr 2014 13:20:51 +0000 (13:20 +0000)
This introduces dedicated ChannelFactory implementations, which allow
for non-default KeyAccessFactory use in the MD5-enabled sockets.

Change-Id: I7ae2e7400076123f6627fdd4b300130da1799539
Signed-off-by: Robert Varga <rovarga@cisco.com>
tcp-md5/netty/src/main/java/org/opendaylight/bgpcep/tcpmd5/netty/MD5NioServerSocketChannel.java
tcp-md5/netty/src/main/java/org/opendaylight/bgpcep/tcpmd5/netty/MD5NioServerSocketChannelFactory.java [new file with mode: 0644]
tcp-md5/netty/src/main/java/org/opendaylight/bgpcep/tcpmd5/netty/MD5NioSocketChannel.java
tcp-md5/netty/src/main/java/org/opendaylight/bgpcep/tcpmd5/netty/MD5NioSocketChannelFactory.java [new file with mode: 0644]

index f8a4dfdd685bbc0198fd762a04477776c6be29a4..5e8cb23923363a11786b9839dd29dfda55e1f7e5 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.bgpcep.tcpmd5.netty;
 
 import io.netty.channel.socket.nio.NioServerSocketChannel;
 
+import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
 import org.opendaylight.bgpcep.tcpmd5.nio.MD5ServerSocketChannel;
 
 /**
@@ -25,6 +26,12 @@ public class MD5NioServerSocketChannel extends NioServerSocketChannel {
                this.config = new ProxyMD5ServerSocketChannelConfig(super.config(), channel);
        }
 
+       public MD5NioServerSocketChannel(final KeyAccessFactory keyAccessFactory) {
+               super();
+               this.channel = new MD5ServerSocketChannel(super.javaChannel(), keyAccessFactory);
+               this.config = new ProxyMD5ServerSocketChannelConfig(super.config(), channel);
+       }
+
        @Override
        public MD5ServerSocketChannelConfig config() {
                return this.config;
diff --git a/tcp-md5/netty/src/main/java/org/opendaylight/bgpcep/tcpmd5/netty/MD5NioServerSocketChannelFactory.java b/tcp-md5/netty/src/main/java/org/opendaylight/bgpcep/tcpmd5/netty/MD5NioServerSocketChannelFactory.java
new file mode 100644 (file)
index 0000000..7ea701a
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2014 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.bgpcep.tcpmd5.netty;
+
+import io.netty.bootstrap.ChannelFactory;
+
+import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
+
+import com.google.common.base.Preconditions;
+
+public final class MD5NioServerSocketChannelFactory implements ChannelFactory<MD5NioServerSocketChannel> {
+       private final KeyAccessFactory keyAccessFactory;
+
+       public MD5NioServerSocketChannelFactory(final KeyAccessFactory keyAccessFactory) {
+               this.keyAccessFactory = Preconditions.checkNotNull(keyAccessFactory);
+       }
+
+       @Override
+       public MD5NioServerSocketChannel newChannel() {
+               return new MD5NioServerSocketChannel(keyAccessFactory);
+       }
+}
index b31ecf8345b62d712e797dbc4bbaf84137db4136..8dee79ad628eb1bffa6986a2edb74dc895275880 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.bgpcep.tcpmd5.netty;
 
 import io.netty.channel.socket.nio.NioSocketChannel;
 
+import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
 import org.opendaylight.bgpcep.tcpmd5.nio.MD5SocketChannel;
 
 /**
@@ -25,6 +26,12 @@ public class MD5NioSocketChannel extends NioSocketChannel {
                this.config = new ProxyMD5SocketChannelConfig(super.config(), channel);
        }
 
+       public MD5NioSocketChannel(final KeyAccessFactory keyAccessFactory) {
+               super();
+               this.channel = new MD5SocketChannel(super.javaChannel(), keyAccessFactory);
+               this.config = new ProxyMD5SocketChannelConfig(super.config(), channel);
+       }
+
        @Override
        public MD5SocketChannelConfig config() {
                return this.config;
diff --git a/tcp-md5/netty/src/main/java/org/opendaylight/bgpcep/tcpmd5/netty/MD5NioSocketChannelFactory.java b/tcp-md5/netty/src/main/java/org/opendaylight/bgpcep/tcpmd5/netty/MD5NioSocketChannelFactory.java
new file mode 100644 (file)
index 0000000..72edf7d
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2014 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.bgpcep.tcpmd5.netty;
+
+import io.netty.bootstrap.ChannelFactory;
+
+import org.opendaylight.bgpcep.tcpmd5.KeyAccessFactory;
+
+import com.google.common.base.Preconditions;
+
+public final class MD5NioSocketChannelFactory implements ChannelFactory<MD5NioSocketChannel> {
+       private final KeyAccessFactory keyAccessFactory;
+
+       public MD5NioSocketChannelFactory(final KeyAccessFactory keyAccessFactory) {
+               this.keyAccessFactory = Preconditions.checkNotNull(keyAccessFactory);
+       }
+
+       @Override
+       public MD5NioSocketChannel newChannel() {
+               return new MD5NioSocketChannel(keyAccessFactory);
+       }
+}