3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.switchmanager.internal;
12 import java.util.Dictionary;
13 import java.util.HashSet;
14 import java.util.Hashtable;
17 import org.apache.felix.dm.Component;
18 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
19 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
20 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
21 import org.opendaylight.controller.sal.inventory.IInventoryService;
22 import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates;
23 import org.opendaylight.controller.statisticsmanager.IStatisticsManager;
24 import org.opendaylight.controller.switchmanager.IInventoryListener;
25 import org.opendaylight.controller.switchmanager.ISpanAware;
26 import org.opendaylight.controller.switchmanager.ISwitchManager;
27 import org.opendaylight.controller.switchmanager.ISwitchManagerAware;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
32 * SwitchManager Bundle Activator
36 public class Activator extends ComponentActivatorAbstractBase {
37 protected static final Logger logger = LoggerFactory
38 .getLogger(Activator.class);
41 * Function called when the activator starts just after some
42 * initializations are done by the
43 * ComponentActivatorAbstractBase.
52 * Function called when the activator stops just before the
53 * cleanup done by ComponentActivatorAbstractBase
57 public void destroy() {
62 * Function that is used to communicate to dependency manager the
63 * list of known implementations for services inside a container
66 * @return An array containing all the CLASS objects that will be
67 * instantiated in order to get an fully working implementation
71 public Object[] getImplementations() {
72 Object[] res = { SwitchManager.class };
77 * Function that is called when configuration of the dependencies
80 * @param c dependency manager Component object, used for
81 * configuring the dependencies exported and imported
82 * @param imp Implementation class that is being configured,
83 * needed as long as the same routine can configure multiple
85 * @param containerName The containerName being configured, this allow
86 * also optional per-container different behavior if needed, usually
87 * should not be the case though.
90 public void configureInstance(Component c, Object imp, String containerName) {
91 if (imp.equals(SwitchManager.class)) {
93 c.setInterface(new String[] {
94 IListenInventoryUpdates.class.getName(),
95 ISwitchManager.class.getName(),
96 IConfigurationContainerAware.class.getName() }, null);
98 // Now lets add a service dependency to make sure the
99 // provider of service exists
100 c.add(createContainerServiceDependency(containerName).setService(
101 IInventoryService.class).setCallbacks(
102 "setInventoryService", "unsetInventoryService")
103 .setRequired(false));
104 c.add(createContainerServiceDependency(containerName).setService(
105 IStatisticsManager.class).setCallbacks(
106 "setStatisticsManager", "unsetStatisticsManager")
107 .setRequired(false));
108 c.add(createContainerServiceDependency(containerName).setService(
109 ISwitchManagerAware.class).setCallbacks(
110 "setSwitchManagerAware", "unsetSwitchManagerAware")
111 .setRequired(false));
112 c.add(createContainerServiceDependency(containerName).setService(
113 IInventoryListener.class).setCallbacks(
114 "setInventoryListener", "unsetInventoryListener")
115 .setRequired(false));
116 c.add(createContainerServiceDependency(containerName).setService(
117 ISpanAware.class).setCallbacks("setSpanAware",
118 "unsetSpanAware").setRequired(false));
119 c.add(createContainerServiceDependency(containerName).setService(
120 IClusterContainerServices.class).setCallbacks(
121 "setClusterContainerService",
122 "unsetClusterContainerService").setRequired(true));
127 protected Object[] getGlobalImplementations() {
128 final Object[] res = { SwitchManagerCLI.class };