Merge "BUG-2218: Keep existing link augmentations during discovery process"
[controller.git] / opendaylight / adsal / routing / dijkstra_implementation / src / main / java / org / opendaylight / controller / routing / dijkstra_implementation / internal / Activator.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
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
8  */
9
10 package org.opendaylight.controller.routing.dijkstra_implementation.internal;
11
12 import java.util.Dictionary;
13 import java.util.Hashtable;
14
15 import org.apache.felix.dm.Component;
16 import org.slf4j.Logger;
17 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.topologymanager.ITopologyManager;
23 import org.opendaylight.controller.topologymanager.ITopologyManagerClusterWideAware;
24 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
25
26 public class Activator extends ComponentActivatorAbstractBase {
27     protected static final Logger logger = LoggerFactory
28             .getLogger(Activator.class);
29
30     /**
31      * Function that is used to communicate to dependency manager the
32      * list of known implementations for services inside a container
33      *
34      *
35      * @return An array containing all the CLASS objects that will be
36      * instantiated in order to get an fully working implementation
37      * Object
38      */
39     @Override
40     public Object[] getImplementations() {
41         Object[] res = { DijkstraImplementation.class };
42         return res;
43     }
44
45     /**
46      * Function that is called when configuration of the dependencies
47      * is required.
48      *
49      * @param c dependency manager Component object, used for
50      * configuring the dependencies exported and imported
51      * @param imp Implementation class that is being configured,
52      * needed as long as the same routine can configure multiple
53      * implementations
54      * @param containerName The containerName being configured, this allow
55      * also optional per-container different behavior if needed, usually
56      * should not be the case though.
57      */
58     @Override
59     public void configureInstance(final Component c, final Object imp, final String containerName) {
60         if (imp.equals(DijkstraImplementation.class)) {
61             // export the service
62             final Dictionary<String, Object> props = new Hashtable<String, Object>();
63             props.put("topoListenerName", "routing.Dijkstra");
64
65             c.setInterface(new String[] { ITopologyManagerClusterWideAware.class.getName(), IRouting.class.getName() },
66                     props);
67
68             // Now lets add a service dependency to make sure the
69             // provider of service exists
70             c.add(createContainerServiceDependency(containerName).setService(IListenRoutingUpdates.class)
71                     .setCallbacks("setListenRoutingUpdates", "unsetListenRoutingUpdates")
72                     .setRequired(false));
73
74             c.add(createContainerServiceDependency(containerName).setService(ISwitchManager.class)
75                     .setCallbacks("setSwitchManager", "unsetSwitchManager")
76                     .setRequired(true));
77
78             c.add(createContainerServiceDependency(containerName).setService(ITopologyManager.class)
79                     .setCallbacks("setTopologyManager", "unsetTopologyManager")
80                     .setRequired(true));
81
82             c.add(createContainerServiceDependency(containerName).setService(IClusterContainerServices.class)
83                     .setCallbacks("setClusterContainerService", "unsetClusterContainerService")
84                     .setRequired(true));
85         }
86     }
87
88     @Override
89     protected Object[] getGlobalImplementations() {
90         final Object[] res = { DijkstraImplementationCLI.class };
91         return res;
92     }
93 }