Migrating caches to TRANSACTIONAL Caches and enabled use1PcForAutoCommitTransactions.
[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.HashSet;
14 import java.util.Hashtable;
15 import java.util.Set;
16
17 import org.apache.felix.dm.Component;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
21 import org.opendaylight.controller.sal.routing.IListenRoutingUpdates;
22 import org.opendaylight.controller.sal.routing.IRouting;
23 import org.opendaylight.controller.switchmanager.ISwitchManager;
24 import org.opendaylight.controller.topologymanager.ITopologyManager;
25 import org.opendaylight.controller.topologymanager.ITopologyManagerClusterWideAware;
26 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
27
28 public class Activator extends ComponentActivatorAbstractBase {
29     protected static final Logger logger = LoggerFactory
30             .getLogger(Activator.class);
31
32     /**
33      * Function called when the activator starts just after some
34      * initializations are done by the
35      * ComponentActivatorAbstractBase.
36      *
37      */
38     @Override
39     public void init() {
40     }
41
42     /**
43      * Function called when the activator stops just before the
44      * cleanup done by ComponentActivatorAbstractBase
45      *
46      */
47     @Override
48     public void destroy() {
49
50     }
51
52     /**
53      * Function that is used to communicate to dependency manager the
54      * list of known implementations for services inside a container
55      *
56      *
57      * @return An array containing all the CLASS objects that will be
58      * instantiated in order to get an fully working implementation
59      * Object
60      */
61     @Override
62     public Object[] getImplementations() {
63         Object[] res = { DijkstraImplementation.class };
64         return res;
65     }
66
67     /**
68      * Function that is called when configuration of the dependencies
69      * is required.
70      *
71      * @param c dependency manager Component object, used for
72      * configuring the dependencies exported and imported
73      * @param imp Implementation class that is being configured,
74      * needed as long as the same routine can configure multiple
75      * implementations
76      * @param containerName The containerName being configured, this allow
77      * also optional per-container different behavior if needed, usually
78      * should not be the case though.
79      */
80     @Override
81     public void configureInstance(final Component c, final Object imp, final String containerName) {
82         if (imp.equals(DijkstraImplementation.class)) {
83             // export the service
84             final Dictionary<String, Object> props = new Hashtable<String, Object>();
85             props.put("topoListenerName", "routing.Dijkstra");
86
87             c.setInterface(new String[] { ITopologyManagerClusterWideAware.class.getName(), IRouting.class.getName() },
88                     props);
89
90             // Now lets add a service dependency to make sure the
91             // provider of service exists
92             c.add(createContainerServiceDependency(containerName).setService(IListenRoutingUpdates.class)
93                     .setCallbacks("setListenRoutingUpdates", "unsetListenRoutingUpdates")
94                     .setRequired(false));
95
96             c.add(createContainerServiceDependency(containerName).setService(ISwitchManager.class)
97                     .setCallbacks("setSwitchManager", "unsetSwitchManager")
98                     .setRequired(true));
99
100             c.add(createContainerServiceDependency(containerName).setService(ITopologyManager.class)
101                     .setCallbacks("setTopologyManager", "unsetTopologyManager")
102                     .setRequired(true));
103
104             c.add(createContainerServiceDependency(containerName).setService(IClusterContainerServices.class)
105                     .setCallbacks("setClusterContainerService", "unsetClusterContainerService")
106                     .setRequired(true));
107         }
108     }
109
110     @Override
111     protected Object[] getGlobalImplementations() {
112         final Object[] res = { DijkstraImplementationCLI.class };
113         return res;
114     }
115 }