2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.hosttracker.internal;
11 import java.util.Dictionary;
12 import java.util.Hashtable;
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;
27 public class Activator extends ComponentActivatorAbstractBase {
28 protected static final Logger logger = LoggerFactory
29 .getLogger(Activator.class);
33 * Function that is used to communicate to dependency manager the list of
34 * known implementations for services inside a container
37 * @return An array containing all the CLASS objects that will be
38 * instantiated in order to get an fully working implementation
42 public Object[] getImplementations() {
43 Object[] res = { DeviceManagerImpl.class };
48 * Function that is called when configuration of the dependencies is
52 * dependency manager Component object, used for configuring the
53 * dependencies exported and imported
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
63 public void configureInstance(Component c, Object imp, String containerName) {
64 if (imp.equals(DeviceManagerImpl.class)) {
66 // XXX - TODO merge with existing APIs
67 Dictionary<String, String> props = new Hashtable<String, String>();
68 props.put("salListenerName", "devicemanager");
71 new String[] { IDeviceService.class.getName(),
72 IfIptoHost.class.getName(),
73 IListenDataPacket.class.getName(),
74 ITopologyManagerAware.class.getName() }, props);
76 c.add(createContainerServiceDependency(containerName)
77 .setService(ISwitchManager.class)
78 .setCallbacks("setSwitchManager", "unsetSwitchManager")
81 c.add(createContainerServiceDependency(containerName)
82 .setService(IDataPacketService.class)
83 .setCallbacks("setDataPacketService",
84 "unsetDataPacketService").setRequired(true));
86 c.add(createContainerServiceDependency(containerName)
87 .setService(IfNewHostNotify.class)
88 .setCallbacks("setNewHostNotify",
89 "unsetNewHostNotify").setRequired(false));
91 c.add(createContainerServiceDependency(containerName)
92 .setService(ITopologyManager.class)
93 .setCallbacks("setTopologyManager", "unsetTopologyManager")
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 !
107 * @return The list of implementations the bundle will support, in Global
111 protected Object[] getGlobalImplementations() {
116 * Configure the dependency for a given instance Global
119 * Component assigned for this instance, this will be what will
120 * be used for configuration
122 * implementation to be configured
123 * @param containerName
124 * container on which the configuration happens
127 protected void configureGlobalInstance(Component c, Object imp) {