Prepare the TopologyManager code for integration testing. Need to have the code in...
[controller.git] / opendaylight / topologymanager / implementation / src / main / java / org / opendaylight / controller / topologymanager / 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.topologymanager.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.opendaylight.controller.clustering.services.ICacheUpdateAware;
19 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
20 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
21 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
22 import org.opendaylight.controller.sal.topology.IListenTopoUpdates;
23 import org.opendaylight.controller.sal.topology.ITopologyService;
24 import org.opendaylight.controller.topologymanager.ITopologyManager;
25 import org.opendaylight.controller.topologymanager.ITopologyManagerAware;
26 import org.opendaylight.controller.topologymanager.ITopologyManagerClusterWideAware;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30 public class Activator extends ComponentActivatorAbstractBase {
31     protected static final Logger logger = LoggerFactory
32             .getLogger(Activator.class);
33
34     /**
35      * Function called when the activator starts just after some
36      * initializations are done by the
37      * ComponentActivatorAbstractBase.
38      *
39      */
40     @Override
41     public void init() {
42
43     }
44
45     /**
46      * Function called when the activator stops just before the
47      * cleanup done by ComponentActivatorAbstractBase
48      *
49      */
50     @Override
51     public void destroy() {
52
53     }
54
55     /**
56      * Function that is used to communicate to dependency manager the
57      * list of known implementations for services inside a container
58      *
59      *
60      * @return An array containing all the CLASS objects that will be
61      * instantiated in order to get an fully working implementation
62      * Object
63      */
64     @Override
65     public Object[] getImplementations() {
66         Object[] res = { TopologyManagerImpl.class };
67         return res;
68     }
69
70     /**
71      * Function that is called when configuration of the dependencies
72      * is required.
73      *
74      * @param c dependency manager Component object, used for
75      * configuring the dependencies exported and imported
76      * @param imp Implementation class that is being configured,
77      * needed as long as the same routine can configure multiple
78      * implementations
79      * @param containerName The containerName being configured, this allow
80      * also optional per-container different behavior if needed, usually
81      * should not be the case though.
82      */
83     @Override
84     public void configureInstance(Component c, Object imp, String containerName) {
85         if (imp.equals(TopologyManagerImpl.class)) {
86             // export the service needed to listen to topology updates
87             Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
88             Set<String> propSet = new HashSet<String>();
89             propSet.add(TopologyManagerImpl.TOPOEDGESDB);
90             props.put("cachenames", propSet);
91
92             c.setInterface(new String[] { IListenTopoUpdates.class.getName(),
93                     ITopologyManager.class.getName(),
94                     IConfigurationContainerAware.class.getName(),
95                     ICacheUpdateAware.class.getName() }, props);
96
97             c.add(createContainerServiceDependency(containerName).setService(
98                     ITopologyService.class).setCallbacks("setTopoService",
99                     "unsetTopoService").setRequired(true));
100
101             // These are all the listeners for a topology manager
102             // updates, there could be many or none
103             c.add(createContainerServiceDependency(containerName).setService(
104                     ITopologyManagerAware.class).setCallbacks(
105                     "setTopologyManagerAware", "unsetTopologyManagerAware")
106                     .setRequired(false));
107
108             // These are all the listeners for a topology manager for the
109             // cluster wide events
110             // updates, there could be many or none
111             c.add(createContainerServiceDependency(containerName).setService(ITopologyManagerClusterWideAware.class)
112                     .setCallbacks("setTopologyManagerClusterWideAware", "unsetTopologyManagerClusterWideAware")
113                     .setRequired(false));
114
115             c.add(createContainerServiceDependency(containerName).setService(
116                     IClusterContainerServices.class).setCallbacks(
117                     "setClusterContainerService",
118                     "unsetClusterContainerService").setRequired(true));
119         }
120     }
121 }