2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.topologymanager.internal;
11 import java.util.Dictionary;
12 import java.util.HashSet;
13 import java.util.Hashtable;
16 import org.apache.felix.dm.Component;
17 import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
18 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
19 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
20 import org.opendaylight.controller.configuration.IConfigurationContainerService;
21 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
22 import org.opendaylight.controller.sal.topology.IListenTopoUpdates;
23 import org.opendaylight.controller.sal.topology.ITopologyService;
24 import org.opendaylight.controller.switchmanager.IInventoryListener;
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.opendaylight.controller.topologymanager.ITopologyManagerShell;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
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 = { TopologyManagerImpl.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(TopologyManagerImpl.class)) {
69 // export the service needed to listen to topology updates
70 Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
71 Set<String> propSet = new HashSet<String>();
72 propSet.add(TopologyManagerImpl.TOPOEDGESDB);
73 props.put("cachenames", propSet);
75 c.setInterface(new String[] { IListenTopoUpdates.class.getName(),
76 IInventoryListener.class.getName(),
77 ITopologyManager.class.getName(),
78 ITopologyManagerShell.class.getName(),
79 IConfigurationContainerAware.class.getName(),
80 ICacheUpdateAware.class.getName() }, props);
82 c.add(createContainerServiceDependency(containerName).setService(
83 ITopologyService.class).setCallbacks("setTopoService",
84 "unsetTopoService").setRequired(true));
86 c.add(createContainerServiceDependency(containerName).setService(
87 ISwitchManager.class).setCallbacks("setSwitchManager",
88 "unsetSwitchManager").setRequired(true));
90 // These are all the listeners for a topology manager
91 // updates, there could be many or none
92 c.add(createContainerServiceDependency(containerName).setService(
93 ITopologyManagerAware.class).setCallbacks(
94 "setTopologyManagerAware", "unsetTopologyManagerAware")
97 // These are all the listeners for a topology manager for the
98 // cluster wide events
99 // updates, there could be many or none
100 c.add(createContainerServiceDependency(containerName).setService(ITopologyManagerClusterWideAware.class)
101 .setCallbacks("setTopologyManagerClusterWideAware", "unsetTopologyManagerClusterWideAware")
102 .setRequired(false));
104 c.add(createContainerServiceDependency(containerName).setService(
105 IClusterContainerServices.class).setCallbacks(
106 "setClusterContainerService",
107 "unsetClusterContainerService").setRequired(true));
109 c.add(createContainerServiceDependency(containerName).setService(
110 IConfigurationContainerService.class).setCallbacks(
111 "setConfigurationContainerService",
112 "unsetConfigurationContainerService").setRequired(true));