Merge "Fixed imports."
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / BGPDispatcherImpl.java
index 35081a209646a64173ebc6e0fc9cee33c70c4d93..a590a630048796ad8fb3ef7e7401a13adb9d5b42 100644 (file)
@@ -16,7 +16,6 @@ import io.netty.util.concurrent.Promise;
 import java.net.InetSocketAddress;
 
 import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
-import org.opendaylight.protocol.bgp.parser.BGPSession;
 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
@@ -30,8 +29,6 @@ import org.opendaylight.protocol.framework.SessionListenerFactory;
 public final class BGPDispatcherImpl extends AbstractDispatcher<BGPSessionImpl, BGPSessionListener> implements BGPDispatcher {
        private final Timer timer = new HashedWheelTimer();
 
-       private BGPSessionNegotiatorFactory snf;
-
        private final BGPHandlerFactory hf;
 
        public BGPDispatcherImpl(final BGPMessageFactory parser) {
@@ -40,24 +37,22 @@ public final class BGPDispatcherImpl extends AbstractDispatcher<BGPSessionImpl,
        }
 
        @Override
-       public Future<? extends BGPSession> createClient(final InetSocketAddress address, final BGPSessionPreferences preferences,
+       public Future<BGPSessionImpl> createClient(final InetSocketAddress address, final BGPSessionPreferences preferences,
                        final BGPSessionListener listener, final ReconnectStrategy strategy) {
-               this.snf = new BGPSessionNegotiatorFactory(this.timer, preferences);
+               final BGPSessionNegotiatorFactory snf = new BGPSessionNegotiatorFactory(this.timer, preferences);
                final SessionListenerFactory<BGPSessionListener> slf = new SessionListenerFactory<BGPSessionListener>() {
-
                        @Override
                        public BGPSessionListener getSessionListener() {
                                return listener;
                        }
                };
-               return super.createClient(address, strategy, slf);
-       }
-
-       @Override
-       public void initializeChannel(final SocketChannel ch, final Promise<BGPSessionImpl> promise,
-                       final SessionListenerFactory<BGPSessionListener> slf) {
-               ch.pipeline().addLast(this.hf.getDecoders());
-               ch.pipeline().addLast("negotiator", this.snf.getSessionNegotiator(slf, ch, promise));
-               ch.pipeline().addLast(this.hf.getEncoders());
+               return super.createClient(address, strategy, new PipelineInitializer<BGPSessionImpl>() {
+                       @Override
+                       public void initializeChannel(final SocketChannel ch, final Promise<BGPSessionImpl> promise) {
+                               ch.pipeline().addLast(hf.getDecoders());
+                               ch.pipeline().addLast("negotiator", snf.getSessionNegotiator(slf, ch, promise));
+                               ch.pipeline().addLast(hf.getEncoders());
+                       }
+               });
        }
 }