Make DispatcherImpl an abstract class
[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.HashedWheelTimer;
11 import io.netty.util.Timer;
12 import io.netty.util.concurrent.Future;
13
14 import java.net.InetSocketAddress;
15
16 import org.opendaylight.protocol.bgp.parser.BGPMessage;
17 import org.opendaylight.protocol.bgp.parser.BGPSession;
18 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
19 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
20 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
21 import org.opendaylight.protocol.framework.AbstractDispatcher;
22 import org.opendaylight.protocol.framework.ProtocolMessageFactory;
23 import org.opendaylight.protocol.framework.ReconnectStrategy;
24
25 import com.google.common.base.Preconditions;
26
27 /**
28  * Implementation of BGPDispatcher.
29  */
30 public final class BGPDispatcherImpl extends AbstractDispatcher implements BGPDispatcher {
31         private final Timer timer = new HashedWheelTimer();
32         private final ProtocolMessageFactory<BGPMessage> parser;
33
34         public BGPDispatcherImpl(final ProtocolMessageFactory<BGPMessage> parser) {
35                 super();
36                 this.parser = Preconditions.checkNotNull(parser);
37         }
38
39         @Override
40         public Future<? extends BGPSession> createClient(final InetSocketAddress address, final BGPSessionPreferences preferences,
41                         final BGPSessionListener listener, final ReconnectStrategy strategy) {
42                 return createClient(address, listener, new BGPSessionNegotiatorFactory(timer, preferences), parser, strategy);
43         }
44 }