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.topologymanager.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.configuration.IConfigurationContainerService;
22 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
23 import org.opendaylight.controller.sal.topology.IListenTopoUpdates;
24 import org.opendaylight.controller.sal.topology.ITopologyService;
25 import org.opendaylight.controller.switchmanager.ISwitchManager;
26 import org.opendaylight.controller.topologymanager.ITopologyManager;
27 import org.opendaylight.controller.topologymanager.ITopologyManagerAware;
28 import org.opendaylight.controller.topologymanager.ITopologyManagerClusterWideAware;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
32 public class Activator extends ComponentActivatorAbstractBase {
33 protected static final Logger logger = LoggerFactory
34 .getLogger(Activator.class);
38 * Function that is used to communicate to dependency manager the
39 * list of known implementations for services inside a container
42 * @return An array containing all the CLASS objects that will be
43 * instantiated in order to get an fully working implementation
47 public Object[] getImplementations() {
48 Object[] res = { TopologyManagerImpl.class };
53 * Function that is called when configuration of the dependencies
56 * @param c dependency manager Component object, used for
57 * configuring the dependencies exported and imported
58 * @param imp Implementation class that is being configured,
59 * needed as long as the same routine can configure multiple
61 * @param containerName The containerName being configured, this allow
62 * also optional per-container different behavior if needed, usually
63 * should not be the case though.
66 public void configureInstance(Component c, Object imp, String containerName) {
67 if (imp.equals(TopologyManagerImpl.class)) {
68 // export the service needed to listen to topology updates
69 Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
70 Set<String> propSet = new HashSet<String>();
71 propSet.add(TopologyManagerImpl.TOPOEDGESDB);
72 props.put("cachenames", propSet);
74 c.setInterface(new String[] { IListenTopoUpdates.class.getName(),
75 ITopologyManager.class.getName(),
76 IConfigurationContainerAware.class.getName(),
77 ICacheUpdateAware.class.getName() }, props);
79 c.add(createContainerServiceDependency(containerName).setService(
80 ITopologyService.class).setCallbacks("setTopoService",
81 "unsetTopoService").setRequired(true));
83 c.add(createContainerServiceDependency(containerName).setService(
84 ISwitchManager.class).setCallbacks("setSwitchManager",
85 "unsetSwitchManager").setRequired(true));
87 // These are all the listeners for a topology manager
88 // updates, there could be many or none
89 c.add(createContainerServiceDependency(containerName).setService(
90 ITopologyManagerAware.class).setCallbacks(
91 "setTopologyManagerAware", "unsetTopologyManagerAware")
94 // These are all the listeners for a topology manager for the
95 // cluster wide events
96 // updates, there could be many or none
97 c.add(createContainerServiceDependency(containerName).setService(ITopologyManagerClusterWideAware.class)
98 .setCallbacks("setTopologyManagerClusterWideAware", "unsetTopologyManagerClusterWideAware")
101 c.add(createContainerServiceDependency(containerName).setService(
102 IClusterContainerServices.class).setCallbacks(
103 "setClusterContainerService",
104 "unsetClusterContainerService").setRequired(true));
106 c.add(createContainerServiceDependency(containerName).setService(
107 IConfigurationContainerService.class).setCallbacks(
108 "setConfigurationContainerService",
109 "unsetConfigurationContainerService").setRequired(true));