Removing references to a prior branded controller
[controller.git] / opendaylight / switchmanager / src / main / java / org / opendaylight / controller / switchmanager / 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.switchmanager.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.inventory.IInventoryService;
23 import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates;
24 import org.opendaylight.controller.switchmanager.IInventoryListener;
25 import org.opendaylight.controller.switchmanager.ISpanAware;
26 import org.opendaylight.controller.switchmanager.ISwitchManager;
27 import org.opendaylight.controller.switchmanager.ISwitchManagerAware;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
30
31 /**
32  * SwitchManager Bundle Activator
33  *
34  *
35  */
36 public class Activator extends ComponentActivatorAbstractBase {
37     protected static final Logger logger = LoggerFactory
38             .getLogger(Activator.class);
39
40     /**
41      * Function called when the activator starts just after some
42      * initializations are done by the
43      * ComponentActivatorAbstractBase.
44      *
45      */
46     public void init() {
47
48     }
49
50     /**
51      * Function called when the activator stops just before the
52      * cleanup done by ComponentActivatorAbstractBase
53      *
54      */
55     public void destroy() {
56
57     }
58
59     /**
60      * Function that is used to communicate to dependency manager the
61      * list of known implementations for services inside a container
62      *
63      *
64      * @return An array containing all the CLASS objects that will be
65      * instantiated in order to get an fully working implementation
66      * Object
67      */
68     public Object[] getImplementations() {
69         Object[] res = { SwitchManagerImpl.class };
70         return res;
71     }
72
73     /**
74      * Function that is called when configuration of the dependencies
75      * is required.
76      *
77      * @param c dependency manager Component object, used for
78      * configuring the dependencies exported and imported
79      * @param imp Implementation class that is being configured,
80      * needed as long as the same routine can configure multiple
81      * implementations
82      * @param containerName The containerName being configured, this allow
83      * also optional per-container different behavior if needed, usually
84      * should not be the case though.
85      */
86     public void configureInstance(Component c, Object imp, String containerName) {
87         if (imp.equals(SwitchManagerImpl.class)) {
88             Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
89             Set<String> propSet = new HashSet<String>();
90             propSet.add("switchmanager.configSaveEvent");
91             props.put("cachenames", propSet);
92             // export the service
93             c.setInterface(new String[] {
94                     IListenInventoryUpdates.class.getName(),
95                     ISwitchManager.class.getName(),
96                     ICacheUpdateAware.class.getName(),
97                     IConfigurationContainerAware.class.getName() }, props);
98
99             // Now lets add a service dependency to make sure the
100             // provider of service exists
101             c.add(createContainerServiceDependency(containerName).setService(
102                     IInventoryService.class).setCallbacks(
103                     "setInventoryService", "unsetInventoryService")
104                     .setRequired(false));
105             c.add(createContainerServiceDependency(containerName).setService(
106                     ISwitchManagerAware.class).setCallbacks(
107                     "setSwitchManagerAware", "unsetSwitchManagerAware")
108                     .setRequired(false));
109             c.add(createContainerServiceDependency(containerName).setService(
110                     IInventoryListener.class).setCallbacks(
111                     "setInventoryListener", "unsetInventoryListener")
112                     .setRequired(false));
113             c.add(createContainerServiceDependency(containerName).setService(
114                     ISpanAware.class).setCallbacks("setSpanAware",
115                     "unsetSpanAware").setRequired(false));
116             c.add(createContainerServiceDependency(containerName).setService(
117                     IClusterContainerServices.class).setCallbacks(
118                     "setClusterContainerService",
119                     "unsetClusterContainerService").setRequired(true));
120         }
121     }
122 }