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;
11 import org.apache.felix.dm.Component;
12 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
13 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
14 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
15 import org.opendaylight.openflowplugin.openflow.md.core.MDController;
16 import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider;
17 import org.osgi.framework.BundleContext;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
22 * Openflow protocol plugin Activator
24 public class Activator extends ComponentActivatorAbstractBase {
25 protected static final Logger logger = LoggerFactory.getLogger(Activator.class);
27 private OpenflowPluginProvider pluginProvider = new OpenflowPluginProvider();
30 * Function called when the activator starts just after some initializations
31 * are done by the ComponentActivatorAbstractBase.
38 * Function called when the activator stops just before the cleanup done by
39 * ComponentActivatorAbstractBase
42 public void destroy() {
46 public void start(BundleContext arg0) {
48 pluginProvider.setContext(arg0);
52 * Function that is used to communicate to dependency manager the list of
53 * known implementations for services inside a container
56 * @return An array containing all the CLASS objects that will be
57 * instantiated in order to get an fully working implementation
60 public Object[] getImplementations() {
66 * Function that is called when configuration of the dependencies is
70 * dependency manager Component object, used for configuring the
71 * dependencies exported and imported
73 * Implementation class that is being configured, needed as long
74 * as the same routine can configure multiple implementations
75 * @param containerName
76 * The containerName being configured, this allow also optional
77 * per-container different behavior if needed, usually should not
80 public void configureInstance(Component c, Object imp, String containerName) {
85 * Function that is used to communicate to dependency manager the list of
86 * known implementations for services that are container independent.
89 * @return An array containing all the CLASS objects that will be
90 * instantiated in order to get an fully working implementation
93 public Object[] getGlobalImplementations() {
94 Object[] res = { MDController.class, pluginProvider };
99 * Function that is called when configuration of the dependencies is
103 * dependency manager Component object, used for configuring the
104 * dependencies exported and imported
106 * Implementation class that is being configured, needed as long
107 * as the same routine can configure multiple implementations
109 public void configureGlobalInstance(Component c, Object imp) {
111 if (imp == pluginProvider) {
112 // c.setInterface(new String[] { IDiscoveryListener.class.getName(),
113 // IContainerListener.class.getName(),
114 // IRefreshInternalProvider.class.getName(),
115 // IInventoryShimExternalListener.class.getName() }, null);
116 c.add(createServiceDependency().setService(BindingAwareBroker.class)
117 .setCallbacks("setBroker", "unsetBroker").setRequired(true));
118 c.add(createServiceDependency().setService(SwitchConnectionProvider.class)
119 .setCallbacks("setSwitchConnectionProvider", "unsetSwitchConnectionProvider").setRequired(true));
120 logger.debug("configuring Binding Aware Provider");