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.ICacheUpdateAware;
19 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
20 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
21 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
22 import org.opendaylight.controller.sal.inventory.IInventoryService;
23 import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates;
24 import org.opendaylight.controller.statisticsmanager.IStatisticsManager;
25 import org.opendaylight.controller.switchmanager.IInventoryListener;
26 import org.opendaylight.controller.switchmanager.ISpanAware;
27 import org.opendaylight.controller.switchmanager.ISwitchManager;
28 import org.opendaylight.controller.switchmanager.ISwitchManagerAware;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
33 * SwitchManager Bundle Activator
37 public class Activator extends ComponentActivatorAbstractBase {
38 protected static final Logger logger = LoggerFactory
39 .getLogger(Activator.class);
42 * Function called when the activator starts just after some
43 * initializations are done by the
44 * ComponentActivatorAbstractBase.
53 * Function called when the activator stops just before the
54 * cleanup done by ComponentActivatorAbstractBase
58 public void destroy() {
63 * Function that is used to communicate to dependency manager the
64 * list of known implementations for services inside a container
67 * @return An array containing all the CLASS objects that will be
68 * instantiated in order to get an fully working implementation
72 public Object[] getImplementations() {
73 Object[] res = { SwitchManager.class };
78 * Function that is called when configuration of the dependencies
81 * @param c dependency manager Component object, used for
82 * configuring the dependencies exported and imported
83 * @param imp Implementation class that is being configured,
84 * needed as long as the same routine can configure multiple
86 * @param containerName The containerName being configured, this allow
87 * also optional per-container different behavior if needed, usually
88 * should not be the case though.
91 public void configureInstance(Component c, Object imp, String containerName) {
92 if (imp.equals(SwitchManager.class)) {
93 Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
94 Set<String> propSet = new HashSet<String>();
95 propSet.add("switchmanager.configSaveEvent");
96 props.put("cachenames", propSet);
98 c.setInterface(new String[] {
99 IListenInventoryUpdates.class.getName(),
100 ISwitchManager.class.getName(),
101 ICacheUpdateAware.class.getName(),
102 IConfigurationContainerAware.class.getName() }, props);
104 // Now lets add a service dependency to make sure the
105 // provider of service exists
106 c.add(createContainerServiceDependency(containerName).setService(
107 IInventoryService.class).setCallbacks(
108 "setInventoryService", "unsetInventoryService")
109 .setRequired(false));
110 c.add(createContainerServiceDependency(containerName).setService(
111 IStatisticsManager.class).setCallbacks(
112 "setStatisticsManager", "unsetStatisticsManager")
113 .setRequired(false));
114 c.add(createContainerServiceDependency(containerName).setService(
115 ISwitchManagerAware.class).setCallbacks(
116 "setSwitchManagerAware", "unsetSwitchManagerAware")
117 .setRequired(false));
118 c.add(createContainerServiceDependency(containerName).setService(
119 IInventoryListener.class).setCallbacks(
120 "setInventoryListener", "unsetInventoryListener")
121 .setRequired(false));
122 c.add(createContainerServiceDependency(containerName).setService(
123 ISpanAware.class).setCallbacks("setSpanAware",
124 "unsetSpanAware").setRequired(false));
125 c.add(createContainerServiceDependency(containerName).setService(
126 IClusterContainerServices.class).setCallbacks(
127 "setClusterContainerService",
128 "unsetClusterContainerService").setRequired(true));
133 protected Object[] getGlobalImplementations() {
134 final Object[] res = { SwitchManagerCLI.class };