Fix the dispatcher not being threadsafe
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / PCEPDispatcherImpl.java
index 52cc2df3c642eb88725037036d4bc23ee14d988b..7740e10a87715b5d27c99624c538dca87aa1c419 100644 (file)
@@ -44,14 +44,13 @@ public class PCEPDispatcherImpl extends AbstractDispatcher<PCEPSessionImpl, PCEP
 
        @Override
        public ChannelFuture createServer(final InetSocketAddress address, final SessionListenerFactory<PCEPSessionListener> listenerFactory) {
-               return super.createServer(address, listenerFactory);
-       }
-
-       @Override
-       public void initializeChannel(final SocketChannel ch, final Promise<PCEPSessionImpl> promise,
-                       final SessionListenerFactory<PCEPSessionListener> listenerFactory) {
-               ch.pipeline().addLast(this.hf.getDecoders());
-               ch.pipeline().addLast("negotiator", this.snf.getSessionNegotiator(listenerFactory, ch, promise));
-               ch.pipeline().addLast(this.hf.getEncoders());
+               return super.createServer(address, new PipelineInitializer<PCEPSessionImpl>() {
+                       @Override
+                       public void initializeChannel(final SocketChannel ch, final Promise<PCEPSessionImpl> promise) {
+                               ch.pipeline().addLast(hf.getDecoders());
+                               ch.pipeline().addLast("negotiator", snf.getSessionNegotiator(listenerFactory, ch, promise));
+                               ch.pipeline().addLast(hf.getEncoders());
+                       }
+               });
        }
 }