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;
11 import io.netty.channel.Channel;
12 import io.netty.util.Timer;
13 import io.netty.util.concurrent.Promise;
14 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
15 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
16 import org.opendaylight.protocol.framework.SessionListenerFactory;
17 import org.opendaylight.protocol.framework.SessionNegotiator;
18 import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
20 import org.opendaylight.yangtools.yang.binding.Notification;
22 public final class BGPClientSessionNegotiatorFactory implements SessionNegotiatorFactory<Notification, BGPSessionImpl, BGPSessionListener> {
23 private final BGPClientSessionValidator validator;
24 private final Timer timer;
25 private final BGPPeerRegistry peerRegistry;
27 public BGPClientSessionNegotiatorFactory(final Timer timer, final AsNumber remoteAs, final BGPPeerRegistry peerRegistry) {
28 this.peerRegistry = peerRegistry;
29 this.timer = Preconditions.checkNotNull(timer);
30 this.validator = new BGPClientSessionValidator(remoteAs);
34 public SessionNegotiator<BGPSessionImpl> getSessionNegotiator(final SessionListenerFactory<BGPSessionListener> factory,
35 final Channel channel, final Promise<BGPSessionImpl> promise) {
36 return new BGPClientSessionNegotiator(this.timer, promise, channel, peerRegistry, validator);