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
9 package org.opendaylight.openflowplugin.openflow.md.core;
11 import java.util.Collection;
12 import java.util.List;
13 import java.util.concurrent.Future;
15 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration;
16 import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
17 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 import com.google.common.collect.Lists;
27 public class MDController {
29 private static final Logger LOG = LoggerFactory
30 .getLogger(MDController.class);
32 private SwitchConnectionProvider switchConnectionProvider;
35 * @param switchConnectionProvider the switchConnectionProvider to set
37 public void setSwitchConnectionProvider(
38 SwitchConnectionProvider switchConnectionProvider) {
39 this.switchConnectionProvider = switchConnectionProvider;
43 * @param switchConnectionProviderToUnset the switchConnectionProvider to unset
45 public void unsetSwitchConnectionProvider(
46 SwitchConnectionProvider switchConnectionProviderToUnset) {
47 if (this.switchConnectionProvider == switchConnectionProviderToUnset) {
48 this.switchConnectionProvider = null;
53 * Function called by dependency manager after "init ()" is called and after
54 * the services provided by the class are registered in the service registry
58 LOG.debug("starting ..");
59 LOG.debug("switchConnectionProvider: "+switchConnectionProvider);
61 SwitchConnectionHandler switchConnectionHandler = new SwitchConnectionHandlerImpl();
62 switchConnectionProvider.setSwitchConnectionHandler(switchConnectionHandler);
63 // configure and startup library servers
64 switchConnectionProvider.configure(getConnectionConfiguration());
65 Future<List<Boolean>> srvStarted = switchConnectionProvider.startup();
69 * @return wished connections configurations
71 private static Collection<ConnectionConfiguration> getConnectionConfiguration() {
72 //TODO:: get config from state manager
73 ConnectionConfiguration configuration = ConnectionConfigurationFactory.getDefault();
74 return Lists.newArrayList(configuration);
78 * Function called by the dependency manager before the services exported by
79 * the component are unregistered, this will be followed by a "destroy ()"
84 LOG.debug("stopping");
88 * Function called by the dependency manager when at least one dependency
89 * become unsatisfied or when the component is shutting down because for
90 * example bundle is being stopped.
93 public void destroy() {