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 org.apache.felix.dm.Component;
13 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
14 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
15 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
16 import org.opendaylight.controller.sal.inventory.IInventoryService;
17 import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates;
18 import org.opendaylight.controller.statisticsmanager.IStatisticsManager;
19 import org.opendaylight.controller.switchmanager.IInventoryListener;
20 import org.opendaylight.controller.switchmanager.ISpanAware;
21 import org.opendaylight.controller.switchmanager.ISwitchManager;
22 import org.opendaylight.controller.switchmanager.ISwitchManagerAware;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
27 * SwitchManager Bundle Activator
31 public class Activator extends ComponentActivatorAbstractBase {
32 protected static final Logger logger = LoggerFactory
33 .getLogger(Activator.class);
36 * Function called when the activator starts just after some
37 * initializations are done by the
38 * ComponentActivatorAbstractBase.
47 * Function called when the activator stops just before the
48 * cleanup done by ComponentActivatorAbstractBase
52 public void destroy() {
57 * Function that is used to communicate to dependency manager the
58 * list of known implementations for services inside a container
61 * @return An array containing all the CLASS objects that will be
62 * instantiated in order to get an fully working implementation
66 public Object[] getImplementations() {
67 Object[] res = { SwitchManager.class };
72 * Function that is called when configuration of the dependencies
75 * @param c dependency manager Component object, used for
76 * configuring the dependencies exported and imported
77 * @param imp Implementation class that is being configured,
78 * needed as long as the same routine can configure multiple
80 * @param containerName The containerName being configured, this allow
81 * also optional per-container different behavior if needed, usually
82 * should not be the case though.
85 public void configureInstance(Component c, Object imp, String containerName) {
86 if (imp.equals(SwitchManager.class)) {
88 c.setInterface(new String[] {
89 IListenInventoryUpdates.class.getName(),
90 ISwitchManager.class.getName(),
91 IConfigurationContainerAware.class.getName() }, null);
93 // Now lets add a service dependency to make sure the
94 // provider of service exists
95 c.add(createContainerServiceDependency(containerName).setService(
96 IInventoryService.class).setCallbacks(
97 "setInventoryService", "unsetInventoryService")
99 c.add(createContainerServiceDependency(containerName).setService(
100 IStatisticsManager.class).setCallbacks(
101 "setStatisticsManager", "unsetStatisticsManager")
102 .setRequired(false));
103 c.add(createContainerServiceDependency(containerName).setService(
104 ISwitchManagerAware.class).setCallbacks(
105 "setSwitchManagerAware", "unsetSwitchManagerAware")
106 .setRequired(false));
107 c.add(createContainerServiceDependency(containerName).setService(
108 IInventoryListener.class).setCallbacks(
109 "setInventoryListener", "unsetInventoryListener")
110 .setRequired(false));
111 c.add(createContainerServiceDependency(containerName).setService(
112 ISpanAware.class).setCallbacks("setSpanAware",
113 "unsetSpanAware").setRequired(false));
114 c.add(createContainerServiceDependency(containerName).setService(
115 IClusterContainerServices.class).setCallbacks(
116 "setClusterContainerService",
117 "unsetClusterContainerService").setRequired(true));
122 protected Object[] getGlobalImplementations() {
123 final Object[] res = { SwitchManagerCLI.class };