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.pcep.impl;
10 import io.netty.channel.ChannelFuture;
11 import io.netty.util.concurrent.Future;
13 import java.io.IOException;
14 import java.net.InetSocketAddress;
15 import java.util.concurrent.ExecutionException;
17 import org.opendaylight.protocol.framework.Dispatcher;
18 import org.opendaylight.protocol.framework.ReconnectStrategy;
19 import org.opendaylight.protocol.framework.SessionListenerFactory;
20 import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
21 import org.opendaylight.protocol.pcep.PCEPDispatcher;
22 import org.opendaylight.protocol.pcep.PCEPMessage;
23 import org.opendaylight.protocol.pcep.PCEPSession;
24 import org.opendaylight.protocol.pcep.PCEPSessionListener;
27 * Implementation of PCEPDispatcher.
29 public class PCEPDispatcherImpl implements PCEPDispatcher {
30 private static final PCEPMessageFactory msgFactory = new PCEPMessageFactory();
31 private final SessionNegotiatorFactory<PCEPMessage, PCEPSessionImpl, PCEPSessionListener> snf;
32 private final Dispatcher dispatcher;
35 * Creates an instance of PCEPDispatcherImpl, gets the default selector and opens it.
37 * @throws IOException if some error occurred during opening the selector
39 public PCEPDispatcherImpl(final Dispatcher dispatcher, final SessionNegotiatorFactory<PCEPMessage, PCEPSessionImpl, PCEPSessionListener> snf) {
40 this.dispatcher = dispatcher;
45 public ChannelFuture createServer(final InetSocketAddress address, final SessionListenerFactory<PCEPSessionListener> listenerFactory) {
46 return this.dispatcher.createServer(address, listenerFactory, snf, msgFactory);
50 * Create client is used for mock purposes only.
52 * @throws ExecutionException
53 * @throws InterruptedException
56 public Future<? extends PCEPSession> createClient(final InetSocketAddress address, final PCEPSessionListener listener, final ReconnectStrategy strategy) {
57 return this.dispatcher.createClient(address, listener, snf, msgFactory, strategy);