BUG-731 : more warnings down
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / AbstractPCEPSessionNegotiatorFactory.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.concurrent.Promise;
12 import org.opendaylight.protocol.framework.SessionListenerFactory;
13 import org.opendaylight.protocol.framework.SessionNegotiator;
14 import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
15 import org.opendaylight.protocol.pcep.PCEPSessionListener;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 /**
21  * SessionNegotiator which takes care of making sure sessions between PCEP peers are kept unique. This needs to be
22  * further subclassed to provide either a client or server factory.
23  */
24 public abstract class AbstractPCEPSessionNegotiatorFactory implements
25         SessionNegotiatorFactory<Message, PCEPSessionImpl, PCEPSessionListener> {
26
27     private static final Logger LOG = LoggerFactory.getLogger(AbstractPCEPSessionNegotiatorFactory.class);
28
29     /**
30      * Create a new negotiator. This method needs to be implemented by subclasses to actually provide a negotiator.
31      *
32      * @param promise Session promise to be completed by the negotiator
33      * @param channel Associated channel
34      * @param sessionId Session ID assigned to the resulting session
35      * @return a PCEP session negotiator
36      */
37     protected abstract AbstractPCEPSessionNegotiator createNegotiator(Promise<PCEPSessionImpl> promise, PCEPSessionListener listener,
38             Channel channel, short sessionId);
39
40     @Override
41     public final SessionNegotiator<PCEPSessionImpl> getSessionNegotiator(final SessionListenerFactory<PCEPSessionListener> factory,
42             final Channel channel, final Promise<PCEPSessionImpl> promise) {
43
44         LOG.debug("Instantiating bootstrap negotiator for channel {}", channel);
45         return new PCEPSessionNegotiator(channel, promise, factory, this);
46     }
47
48 }