2ee1583af7ebebe7f089f2992220f69e25338ade
[controller.git] / opendaylight / 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 import org.apache.felix.dm.Component;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
17
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;
25
26 public class Activator extends ComponentActivatorAbstractBase {
27     protected static final Logger logger = LoggerFactory
28             .getLogger(Activator.class);
29
30     /**
31      * Function called when the activator starts just after some
32      * initializations are done by the
33      * ComponentActivatorAbstractBase.
34      *
35      */
36     public void init() {
37     }
38
39     /**
40      * Function called when the activator stops just before the
41      * cleanup done by ComponentActivatorAbstractBase
42      *
43      */
44     public void destroy() {
45
46     }
47
48     /**
49      * Function that is used to communicate to dependency manager the
50      * list of known implementations for services inside a container
51      *
52      *
53      * @return An array containing all the CLASS objects that will be
54      * instantiated in order to get an fully working implementation
55      * Object
56      */
57     public Object[] getImplementations() {
58         Object[] res = { DijkstraImplementation.class };
59         return res;
60     }
61
62     /**
63      * Function that is called when configuration of the dependencies
64      * is required.
65      *
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
70      * implementations
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.
74      */
75     public void configureInstance(Component c, Object imp, String containerName) {
76         if (imp.equals(DijkstraImplementation.class)) {
77             // export the service
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);
82
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")
88                     .setRequired(false));
89
90             c.add(createContainerServiceDependency(containerName).setService(
91                     ISwitchManager.class).setCallbacks("setSwitchManager",
92                     "unsetSwitchManager").setRequired(true));
93
94             c.add(createContainerServiceDependency(containerName).setService(
95                     ITopologyManager.class).setCallbacks("setTopologyManager",
96                     "unsetTopologyManager").setRequired(true));
97
98             c.add(createContainerServiceDependency(containerName).setService(
99                     IReadService.class).setCallbacks("setReadService",
100                     "unsetReadService").setRequired(true));
101         }
102     }
103 }