BUG-58: refactor to take advantage of netty
[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 io.netty.channel.Channel;
11 import io.netty.util.Timer;
12 import io.netty.util.concurrent.Promise;
13
14 import org.opendaylight.protocol.pcep.PCEPSessionListener;
15 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
16
17 import com.google.common.base.Preconditions;
18
19 public final class DefaultPCEPSessionNegotiatorFactory extends AbstractPCEPSessionNegotiatorFactory {
20         private final PCEPOpenObject localPrefs;
21         private final int maxUnknownMessages;
22         private final Timer timer;
23
24         public DefaultPCEPSessionNegotiatorFactory(final Timer timer, final PCEPOpenObject localPrefs,
25                         final int maxUnknownMessages) {
26                 this.timer = Preconditions.checkNotNull(timer);
27                 this.localPrefs = Preconditions.checkNotNull(localPrefs);
28                 this.maxUnknownMessages = maxUnknownMessages;
29         }
30
31         @Override
32         protected AbstractPCEPSessionNegotiator createNegotiator(final Promise<PCEPSessionImpl> promise,
33                         final PCEPSessionListener listener , final Channel channel, final short sessionId) {
34                 return new DefaultPCEPSessionNegotiator(timer, promise, channel, listener, sessionId, maxUnknownMessages, localPrefs);
35         }
36 }