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.routing.dijkstra_implementation.internal;
12 import java.util.Dictionary;
13 import java.util.Hashtable;
14 import org.apache.felix.dm.Component;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
19 import org.opendaylight.controller.sal.routing.IListenRoutingUpdates;
20 import org.opendaylight.controller.sal.routing.IRouting;
21 import org.opendaylight.controller.switchmanager.ISwitchManager;
22 import org.opendaylight.controller.sal.reader.IReadService;
23 import org.opendaylight.controller.topologymanager.ITopologyManager;
24 import org.opendaylight.controller.topologymanager.ITopologyManagerAware;
26 public class Activator extends ComponentActivatorAbstractBase {
27 protected static final Logger logger = LoggerFactory
28 .getLogger(Activator.class);
31 * Function called when the activator starts just after some
32 * initializations are done by the
33 * ComponentActivatorAbstractBase.
40 * Function called when the activator stops just before the
41 * cleanup done by ComponentActivatorAbstractBase
44 public void destroy() {
49 * Function that is used to communicate to dependency manager the
50 * list of known implementations for services inside a container
53 * @return An array containing all the CLASS objects that will be
54 * instantiated in order to get an fully working implementation
57 public Object[] getImplementations() {
58 Object[] res = { DijkstraImplementation.class };
63 * Function that is called when configuration of the dependencies
66 * @param c dependency manager Component object, used for
67 * configuring the dependencies exported and imported
68 * @param imp Implementation class that is being configured,
69 * needed as long as the same routine can configure multiple
71 * @param containerName The containerName being configured, this allow
72 * also optional per-container different behavior if needed, usually
73 * should not be the case though.
75 public void configureInstance(Component c, Object imp, String containerName) {
76 if (imp.equals(DijkstraImplementation.class)) {
78 Dictionary<String, String> props = new Hashtable<String, String>();
79 props.put("topoListenerName", "routing.Dijkstra");
80 c.setInterface(new String[] { ITopologyManagerAware.class.getName(),
81 IRouting.class.getName() }, props);
83 // Now lets add a service dependency to make sure the
84 // provider of service exists
85 c.add(createContainerServiceDependency(containerName).setService(
86 IListenRoutingUpdates.class).setCallbacks(
87 "setLIstenRoutingUpdates", "unsetLIstenRoutingUpdates")
90 c.add(createContainerServiceDependency(containerName).setService(
91 ISwitchManager.class).setCallbacks("setSwitchManager",
92 "unsetSwitchManager").setRequired(true));
94 c.add(createContainerServiceDependency(containerName).setService(
95 ITopologyManager.class).setCallbacks("setTopologyManager",
96 "unsetTopologyManager").setRequired(true));
98 c.add(createContainerServiceDependency(containerName).setService(
99 IReadService.class).setCallbacks("setReadService",
100 "unsetReadService").setRequired(true));