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.IClusterContainerServices;
19 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
20 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
21 import org.opendaylight.controller.sal.topology.IListenTopoUpdates;
22 import org.opendaylight.controller.sal.topology.ITopologyService;
23 import org.opendaylight.controller.topologymanager.ITopologyManager;
24 import org.opendaylight.controller.topologymanager.ITopologyManagerAware;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
28 public class Activator extends ComponentActivatorAbstractBase {
29 protected static final Logger logger = LoggerFactory
30 .getLogger(Activator.class);
33 * Function called when the activator starts just after some
34 * initializations are done by the
35 * ComponentActivatorAbstractBase.
43 * Function called when the activator stops just before the
44 * cleanup done by ComponentActivatorAbstractBase
47 public void destroy() {
52 * Function that is used to communicate to dependency manager the
53 * list of known implementations for services inside a container
56 * @return An array containing all the CLASS objects that will be
57 * instantiated in order to get an fully working implementation
60 public Object[] getImplementations() {
61 Object[] res = { TopologyManagerImpl.class };
66 * Function that is called when configuration of the dependencies
69 * @param c dependency manager Component object, used for
70 * configuring the dependencies exported and imported
71 * @param imp Implementation class that is being configured,
72 * needed as long as the same routine can configure multiple
74 * @param containerName The containerName being configured, this allow
75 * also optional per-container different behavior if needed, usually
76 * should not be the case though.
78 public void configureInstance(Component c, Object imp, String containerName) {
79 if (imp.equals(TopologyManagerImpl.class)) {
80 // export the service needed to listen to topology updates
81 Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
82 Set<String> propSet = new HashSet<String>();
83 propSet.add("topologymanager.configSaveEvent");
84 props.put("cachenames", propSet);
86 c.setInterface(new String[] { IListenTopoUpdates.class.getName(),
87 ITopologyManager.class.getName(),
88 IConfigurationContainerAware.class.getName() }, props);
90 c.add(createContainerServiceDependency(containerName).setService(
91 ITopologyService.class).setCallbacks("setTopoService",
92 "unsetTopoService").setRequired(true));
94 // These are all the listeners for a topology manager
95 // updates, there could be many or none
96 c.add(createContainerServiceDependency(containerName).setService(
97 ITopologyManagerAware.class).setCallbacks(
98 "setTopologyManagerAware", "unsetTopologyManagerAware")
101 c.add(createContainerServiceDependency(containerName).setService(
102 IClusterContainerServices.class).setCallbacks(
103 "setClusterContainerService",
104 "unsetClusterContainerService").setRequired(true));