Move init and destroy empty impl from Activator classes. Have only one
[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     /**
36      * Function that is used to communicate to dependency manager the
37      * list of known implementations for services inside a container
38      *
39      *
40      * @return An array containing all the CLASS objects that will be
41      * instantiated in order to get an fully working implementation
42      * Object
43      */
44     @Override
45     public Object[] getImplementations() {
46         Object[] res = { TopologyManagerImpl.class };
47         return res;
48     }
49
50     /**
51      * Function that is called when configuration of the dependencies
52      * is required.
53      *
54      * @param c dependency manager Component object, used for
55      * configuring the dependencies exported and imported
56      * @param imp Implementation class that is being configured,
57      * needed as long as the same routine can configure multiple
58      * implementations
59      * @param containerName The containerName being configured, this allow
60      * also optional per-container different behavior if needed, usually
61      * should not be the case though.
62      */
63     @Override
64     public void configureInstance(Component c, Object imp, String containerName) {
65         if (imp.equals(TopologyManagerImpl.class)) {
66             // export the service needed to listen to topology updates
67             Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
68             Set<String> propSet = new HashSet<String>();
69             propSet.add(TopologyManagerImpl.TOPOEDGESDB);
70             props.put("cachenames", propSet);
71
72             c.setInterface(new String[] { IListenTopoUpdates.class.getName(),
73                     ITopologyManager.class.getName(),
74                     IConfigurationContainerAware.class.getName(),
75                     ICacheUpdateAware.class.getName() }, props);
76
77             c.add(createContainerServiceDependency(containerName).setService(
78                     ITopologyService.class).setCallbacks("setTopoService",
79                     "unsetTopoService").setRequired(true));
80
81             // These are all the listeners for a topology manager
82             // updates, there could be many or none
83             c.add(createContainerServiceDependency(containerName).setService(
84                     ITopologyManagerAware.class).setCallbacks(
85                     "setTopologyManagerAware", "unsetTopologyManagerAware")
86                     .setRequired(false));
87
88             // These are all the listeners for a topology manager for the
89             // cluster wide events
90             // updates, there could be many or none
91             c.add(createContainerServiceDependency(containerName).setService(ITopologyManagerClusterWideAware.class)
92                     .setCallbacks("setTopologyManagerClusterWideAware", "unsetTopologyManagerClusterWideAware")
93                     .setRequired(false));
94
95             c.add(createContainerServiceDependency(containerName).setService(
96                     IClusterContainerServices.class).setCallbacks(
97                     "setClusterContainerService",
98                     "unsetClusterContainerService").setRequired(true));
99         }
100     }
101 }