2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.protocol.bgp.rib.impl;
10 import com.google.common.base.Preconditions;
12 import io.netty.channel.Channel;
13 import io.netty.util.Timer;
14 import io.netty.util.concurrent.Promise;
16 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
17 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
18 import org.opendaylight.protocol.framework.SessionListenerFactory;
19 import org.opendaylight.protocol.framework.SessionNegotiator;
20 import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
21 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
22 import org.opendaylight.yangtools.yang.binding.Notification;
24 public final class BGPSessionNegotiatorFactory implements SessionNegotiatorFactory<Notification, BGPSessionImpl, BGPSessionListener> {
25 private final BGPSessionPreferences initialPrefs;
26 private final AsNumber remoteAs;
27 private final Timer timer;
29 public BGPSessionNegotiatorFactory(final Timer timer, final BGPSessionPreferences initialPrefs, final AsNumber remoteAs) {
30 this.timer = Preconditions.checkNotNull(timer);
31 this.initialPrefs = Preconditions.checkNotNull(initialPrefs);
32 this.remoteAs = Preconditions.checkNotNull(remoteAs);
36 public SessionNegotiator<BGPSessionImpl> getSessionNegotiator(final SessionListenerFactory<BGPSessionListener> factory,
37 final Channel channel, final Promise<BGPSessionImpl> promise) {
38 return new BGPSessionNegotiator(this.timer, promise, channel, this.initialPrefs, remoteAs, factory.getSessionListener());