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.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)) {
92 Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
93 Set<String> propSet = new HashSet<String>();
94 propSet.add("switchmanager.configSaveEvent");
95 props.put("cachenames", propSet);
97 c.setInterface(new String[] {
98 IListenInventoryUpdates.class.getName(),
99 ISwitchManager.class.getName(),
100 ICacheUpdateAware.class.getName(),
101 IConfigurationContainerAware.class.getName() }, props);
103 // Now lets add a service dependency to make sure the
104 // provider of service exists
105 c.add(createContainerServiceDependency(containerName).setService(
106 IInventoryService.class).setCallbacks(
107 "setInventoryService", "unsetInventoryService")
108 .setRequired(false));
109 c.add(createContainerServiceDependency(containerName).setService(
110 ISwitchManagerAware.class).setCallbacks(
111 "setSwitchManagerAware", "unsetSwitchManagerAware")
112 .setRequired(false));
113 c.add(createContainerServiceDependency(containerName).setService(
114 IInventoryListener.class).setCallbacks(
115 "setInventoryListener", "unsetInventoryListener")
116 .setRequired(false));
117 c.add(createContainerServiceDependency(containerName).setService(
118 ISpanAware.class).setCallbacks("setSpanAware",
119 "unsetSpanAware").setRequired(false));
120 c.add(createContainerServiceDependency(containerName).setService(
121 IClusterContainerServices.class).setCallbacks(
122 "setClusterContainerService",
123 "unsetClusterContainerService").setRequired(true));
128 protected Object[] getGlobalImplementations() {
129 final Object[] res = { SwitchManagerCLI.class };