BUG 2302 : odl-clustering-test-app should not be part of the odl-restconf-all feature set
[controller.git] / opendaylight / adsal / hosttracker_new / implementation / src / main / java / org / opendaylight / controller / hosttracker / internal / Activator.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.hosttracker.internal;
10
11 import java.util.Dictionary;
12 import java.util.Hashtable;
13
14 import org.apache.felix.dm.Component;
15 import org.opendaylight.controller.hosttracker.IDeviceService;
16 import org.opendaylight.controller.hosttracker.IfIptoHost;
17 import org.opendaylight.controller.hosttracker.IfNewHostNotify;
18 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
19 import org.opendaylight.controller.sal.packet.IDataPacketService;
20 import org.opendaylight.controller.sal.packet.IListenDataPacket;
21 import org.opendaylight.controller.switchmanager.ISwitchManager;
22 import org.opendaylight.controller.topologymanager.ITopologyManager;
23 import org.opendaylight.controller.topologymanager.ITopologyManagerAware;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26
27 public class Activator extends ComponentActivatorAbstractBase {
28     protected static final Logger logger = LoggerFactory
29             .getLogger(Activator.class);
30
31
32     /**
33      * Function that is used to communicate to dependency manager the list of
34      * known implementations for services inside a container
35      *
36      *
37      * @return An array containing all the CLASS objects that will be
38      *         instantiated in order to get an fully working implementation
39      *         Object
40      */
41     @Override
42     public Object[] getImplementations() {
43         Object[] res = { DeviceManagerImpl.class };
44         return res;
45     }
46
47     /**
48      * Function that is called when configuration of the dependencies is
49      * required.
50      *
51      * @param c
52      *            dependency manager Component object, used for configuring the
53      *            dependencies exported and imported
54      * @param imp
55      *            Implementation class that is being configured, needed as long
56      *            as the same routine can configure multiple implementations
57      * @param containerName
58      *            The containerName being configured, this allow also optional
59      *            per-container different behavior if needed, usually should not
60      *            be the case though.
61      */
62     @Override
63     public void configureInstance(Component c, Object imp, String containerName) {
64         if (imp.equals(DeviceManagerImpl.class)) {
65             // export the service
66             // XXX - TODO merge with existing APIs
67             Dictionary<String, String> props = new Hashtable<String, String>();
68             props.put("salListenerName", "devicemanager");
69
70             c.setInterface(
71                     new String[] { IDeviceService.class.getName(),
72                             IfIptoHost.class.getName(),
73                             IListenDataPacket.class.getName(),
74                             ITopologyManagerAware.class.getName() }, props);
75
76             c.add(createContainerServiceDependency(containerName)
77                     .setService(ISwitchManager.class)
78                     .setCallbacks("setSwitchManager", "unsetSwitchManager")
79                     .setRequired(false));
80
81             c.add(createContainerServiceDependency(containerName)
82                     .setService(IDataPacketService.class)
83                     .setCallbacks("setDataPacketService",
84                             "unsetDataPacketService").setRequired(true));
85
86             c.add(createContainerServiceDependency(containerName)
87                     .setService(IfNewHostNotify.class)
88                     .setCallbacks("setNewHostNotify",
89                             "unsetNewHostNotify").setRequired(false));
90
91             c.add(createContainerServiceDependency(containerName)
92                     .setService(ITopologyManager.class)
93                     .setCallbacks("setTopologyManager", "unsetTopologyManager")
94                     .setRequired(false));
95         }
96     }
97
98     /**
99      * Method which tells how many Global implementations are supported by the
100      * bundle. This way we can tune the number of components created. This
101      * components will be created ONLY at the time of bundle startup and will be
102      * destroyed only at time of bundle destruction, this is the major
103      * difference with the implementation retrieved via getImplementations where
104      * all of them are assumed to be in a container !
105      *
106      *
107      * @return The list of implementations the bundle will support, in Global
108      *         version
109      */
110     @Override
111     protected Object[] getGlobalImplementations() {
112         return null;
113     }
114
115     /**
116      * Configure the dependency for a given instance Global
117      *
118      * @param c
119      *            Component assigned for this instance, this will be what will
120      *            be used for configuration
121      * @param imp
122      *            implementation to be configured
123      * @param containerName
124      *            container on which the configuration happens
125      */
126     @Override
127     protected void configureGlobalInstance(Component c, Object imp) {
128
129     }
130
131 }