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.clustering.services.IClusterGlobalServices;
15 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
16 import org.opendaylight.controller.configuration.IConfigurationContainerService;
17 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
18 import org.opendaylight.controller.sal.inventory.IInventoryService;
19 import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates;
20 import org.opendaylight.controller.statisticsmanager.IStatisticsManager;
21 import org.opendaylight.controller.switchmanager.IInventoryListener;
22 import org.opendaylight.controller.switchmanager.ISpanAware;
23 import org.opendaylight.controller.switchmanager.ISwitchManager;
24 import org.opendaylight.controller.switchmanager.ISwitchManagerAware;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
29 * SwitchManager Bundle Activator
33 public class Activator extends ComponentActivatorAbstractBase {
34 protected static final Logger logger = LoggerFactory
35 .getLogger(Activator.class);
39 * Function that is used to communicate to dependency manager the
40 * list of known implementations for services inside a container
43 * @return An array containing all the CLASS objects that will be
44 * instantiated in order to get an fully working implementation
48 public Object[] getImplementations() {
49 Object[] res = { SwitchManager.class };
54 * Function that is called when configuration of the dependencies
57 * @param c dependency manager Component object, used for
58 * configuring the dependencies exported and imported
59 * @param imp Implementation class that is being configured,
60 * needed as long as the same routine can configure multiple
62 * @param containerName The containerName being configured, this allow
63 * also optional per-container different behavior if needed, usually
64 * should not be the case though.
67 public void configureInstance(Component c, Object imp, String containerName) {
68 if (imp.equals(SwitchManager.class)) {
70 c.setInterface(new String[] {
71 IListenInventoryUpdates.class.getName(),
72 ISwitchManager.class.getName(),
73 IConfigurationContainerAware.class.getName() }, null);
75 // Now lets add a service dependency to make sure the
76 // provider of service exists
77 c.add(createContainerServiceDependency(containerName).setService(
78 IInventoryService.class).setCallbacks(
79 "setInventoryService", "unsetInventoryService")
81 c.add(createContainerServiceDependency(containerName).setService(
82 IStatisticsManager.class).setCallbacks(
83 "setStatisticsManager", "unsetStatisticsManager")
85 c.add(createContainerServiceDependency(containerName).setService(
86 ISwitchManagerAware.class).setCallbacks(
87 "setSwitchManagerAware", "unsetSwitchManagerAware")
89 c.add(createContainerServiceDependency(containerName).setService(
90 IInventoryListener.class).setCallbacks(
91 "setInventoryListener", "unsetInventoryListener")
93 c.add(createContainerServiceDependency(containerName).setService(
94 ISpanAware.class).setCallbacks("setSpanAware",
95 "unsetSpanAware").setRequired(false));
96 c.add(createContainerServiceDependency(containerName).setService(
97 IClusterContainerServices.class).setCallbacks(
98 "setClusterContainerService",
99 "unsetClusterContainerService").setRequired(true));
100 c.add(createContainerServiceDependency(containerName).setService(
101 IConfigurationContainerService.class).setCallbacks(
102 "setConfigurationContainerService",
103 "unsetConfigurationContainerService").setRequired(true));
104 c.add(createServiceDependency()
105 .setService(IControllerProperties.class)
106 .setCallbacks("setControllerProperties", "unsetControllerProperties")
115 protected Object[] getGlobalImplementations() {
116 final Object[] res = { ControllerProperties.class, SwitchManagerCLI.class };
124 public void configureGlobalInstance(Component c, Object imp) {
125 if (imp.equals(ControllerProperties.class)) {
126 c.setInterface(new String[] { IControllerProperties.class.getName() }, null);
128 c.add(createServiceDependency()
129 .setService(IClusterGlobalServices.class)
130 .setCallbacks("setClusterService", "unsetClusterService")