Merge "When a node is going down, remove edges in both directions associated with...
[controller.git] / opendaylight / topologymanager / 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.IClusterContainerServices;
19 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
20 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
21 import org.opendaylight.controller.sal.topology.IListenTopoUpdates;
22 import org.opendaylight.controller.sal.topology.ITopologyService;
23 import org.opendaylight.controller.topologymanager.ITopologyManager;
24 import org.opendaylight.controller.topologymanager.ITopologyManagerAware;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
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     public void init() {
39
40     }
41
42     /**
43      * Function called when the activator stops just before the
44      * cleanup done by ComponentActivatorAbstractBase
45      *
46      */
47     public void destroy() {
48
49     }
50
51     /**
52      * Function that is used to communicate to dependency manager the
53      * list of known implementations for services inside a container
54      *
55      *
56      * @return An array containing all the CLASS objects that will be
57      * instantiated in order to get an fully working implementation
58      * Object
59      */
60     public Object[] getImplementations() {
61         Object[] res = { TopologyManagerImpl.class };
62         return res;
63     }
64
65     /**
66      * Function that is called when configuration of the dependencies
67      * is required.
68      *
69      * @param c dependency manager Component object, used for
70      * configuring the dependencies exported and imported
71      * @param imp Implementation class that is being configured,
72      * needed as long as the same routine can configure multiple
73      * implementations
74      * @param containerName The containerName being configured, this allow
75      * also optional per-container different behavior if needed, usually
76      * should not be the case though.
77      */
78     public void configureInstance(Component c, Object imp, String containerName) {
79         if (imp.equals(TopologyManagerImpl.class)) {
80             // export the service needed to listen to topology updates
81             Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
82             Set<String> propSet = new HashSet<String>();
83             propSet.add("topologymanager.configSaveEvent");
84             props.put("cachenames", propSet);
85
86             c.setInterface(new String[] { IListenTopoUpdates.class.getName(),
87                     ITopologyManager.class.getName(),
88                     IConfigurationContainerAware.class.getName() }, props);
89
90             c.add(createContainerServiceDependency(containerName).setService(
91                     ITopologyService.class).setCallbacks("setTopoService",
92                     "unsetTopoService").setRequired(true));
93
94             // These are all the listeners for a topology manager
95             // updates, there could be many or none
96             c.add(createContainerServiceDependency(containerName).setService(
97                     ITopologyManagerAware.class).setCallbacks(
98                     "setTopologyManagerAware", "unsetTopologyManagerAware")
99                     .setRequired(false));
100
101             c.add(createContainerServiceDependency(containerName).setService(
102                     IClusterContainerServices.class).setCallbacks(
103                     "setClusterContainerService",
104                     "unsetClusterContainerService").setRequired(true));
105         }
106     }
107 }