BUG-55: make sure session initialization asynchronous
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / BGPDispatcherImpl.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.protocol.bgp.rib.impl;
9
10 import io.netty.util.concurrent.Future;
11
12 import java.io.Closeable;
13 import java.io.IOException;
14
15 import org.opendaylight.protocol.bgp.parser.BGPSession;
16 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPConnection;
17 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
18 import org.opendaylight.protocol.framework.Dispatcher;
19 import org.opendaylight.protocol.framework.ProtocolMessageFactory;
20
21 /**
22  * Implementation of BGPDispatcher.
23  */
24 public final class BGPDispatcherImpl implements BGPDispatcher, Closeable {
25
26         private final Dispatcher dispatcher;
27
28         public BGPDispatcherImpl(final Dispatcher dispatcher) throws IOException {
29                 this.dispatcher = dispatcher;
30         }
31
32         @Override
33         public Future<? extends BGPSession> createClient(final BGPConnection connection, final ProtocolMessageFactory parser) throws IOException {
34                 return this.dispatcher.createClient(connection, new BGPSessionFactory(parser));
35         }
36
37         public Dispatcher getDispatcher() {
38                 return this.dispatcher;
39         }
40
41         @Override
42         public void close() {
43                 // This is only necessary for configuration interaction
44         }
45 }