004c8c1dc694a5c52f5d1cacdd2bc414e7626197
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / DefaultPCEPSessionNegotiatorFactory.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.pcep.impl;
9
10 import com.google.common.base.Preconditions;
11
12 import io.netty.channel.Channel;
13 import io.netty.util.concurrent.Promise;
14
15 import org.opendaylight.protocol.pcep.PCEPSessionListener;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
17
18 public final class DefaultPCEPSessionNegotiatorFactory extends AbstractPCEPSessionNegotiatorFactory {
19     private final Open localPrefs;
20     private final int maxUnknownMessages;
21
22     public DefaultPCEPSessionNegotiatorFactory(final Open localPrefs, final int maxUnknownMessages) {
23         this.localPrefs = Preconditions.checkNotNull(localPrefs);
24         this.maxUnknownMessages = maxUnknownMessages;
25     }
26
27     @Override
28     protected AbstractPCEPSessionNegotiator createNegotiator(final Promise<PCEPSessionImpl> promise, final PCEPSessionListener listener,
29             final Channel channel, final short sessionId) {
30         return new DefaultPCEPSessionNegotiator(promise, channel, listener, sessionId, this.maxUnknownMessages, this.localPrefs);
31     }
32 }