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