Add IfNewHostNotify to DeviceManager
[controller.git] / opendaylight / 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     @Override
32     protected void init() {
33
34     }
35
36     @Override
37     protected void destroy() {
38
39     }
40
41     /**
42      * Function that is used to communicate to dependency manager the list of
43      * known implementations for services inside a container
44      *
45      *
46      * @return An array containing all the CLASS objects that will be
47      *         instantiated in order to get an fully working implementation
48      *         Object
49      */
50     @Override
51     public Object[] getImplementations() {
52         Object[] res = { DeviceManagerImpl.class };
53         return res;
54     }
55
56     /**
57      * Function that is called when configuration of the dependencies is
58      * required.
59      *
60      * @param c
61      *            dependency manager Component object, used for configuring the
62      *            dependencies exported and imported
63      * @param imp
64      *            Implementation class that is being configured, needed as long
65      *            as the same routine can configure multiple implementations
66      * @param containerName
67      *            The containerName being configured, this allow also optional
68      *            per-container different behavior if needed, usually should not
69      *            be the case though.
70      */
71     @Override
72     public void configureInstance(Component c, Object imp, String containerName) {
73         if (imp.equals(DeviceManagerImpl.class)) {
74             // export the service
75             // XXX - TODO merge with existing APIs
76             Dictionary<String, String> props = new Hashtable<String, String>();
77             props.put("salListenerName", "devicemanager");
78
79             c.setInterface(
80                     new String[] { IDeviceService.class.getName(),
81                             IfIptoHost.class.getName(),
82                             IListenDataPacket.class.getName(),
83                             ITopologyManagerAware.class.getName() }, props);
84
85             c.add(createContainerServiceDependency(containerName)
86                     .setService(ISwitchManager.class)
87                     .setCallbacks("setSwitchManager", "unsetSwitchManager")
88                     .setRequired(false));
89
90             c.add(createContainerServiceDependency(containerName)
91                     .setService(IDataPacketService.class)
92                     .setCallbacks("setDataPacketService",
93                             "unsetDataPacketService").setRequired(true));
94
95             c.add(createContainerServiceDependency(containerName)
96                     .setService(IfNewHostNotify.class)
97                     .setCallbacks("setNewHostNotify",
98                             "unsetNewHostNotify").setRequired(false));
99
100             // c.add(createContainerServiceDependency(containerName).setService(
101             // IClusterContainerServices.class).setCallbacks(
102             // "setClusterContainerService",
103             // "unsetClusterContainerService").setRequired(true));
104             c.add(createContainerServiceDependency(containerName)
105                     .setService(ITopologyManager.class)
106                     .setCallbacks("setTopologyManager", "unsetTopologyManager")
107                     .setRequired(false));
108         }
109     }
110
111     /**
112      * Method which tells how many Global implementations are supported by the
113      * bundle. This way we can tune the number of components created. This
114      * components will be created ONLY at the time of bundle startup and will be
115      * destroyed only at time of bundle destruction, this is the major
116      * difference with the implementation retrieved via getImplementations where
117      * all of them are assumed to be in a container !
118      *
119      *
120      * @return The list of implementations the bundle will support, in Global
121      *         version
122      */
123     @Override
124     protected Object[] getGlobalImplementations() {
125         return null;
126     }
127
128     /**
129      * Configure the dependency for a given instance Global
130      *
131      * @param c
132      *            Component assigned for this instance, this will be what will
133      *            be used for configuration
134      * @param imp
135      *            implementation to be configured
136      * @param containerName
137      *            container on which the configuration happens
138      */
139     @Override
140     protected void configureGlobalInstance(Component c, Object imp) {
141
142     }
143
144 }