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.sal.core.ComponentActivatorAbstractBase;
18 import org.opendaylight.controller.sal.packet.IDataPacketService;
19 import org.opendaylight.controller.sal.packet.IListenDataPacket;
20 import org.opendaylight.controller.switchmanager.ISwitchManager;
21 import org.opendaylight.controller.topologymanager.ITopologyManager;
22 import org.opendaylight.controller.topologymanager.ITopologyManagerAware;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
26 public class Activator extends ComponentActivatorAbstractBase {
27 protected static final Logger logger = LoggerFactory
28 .getLogger(Activator.class);
31 protected void init() {
36 protected void destroy() {
41 * Function that is used to communicate to dependency manager the list of
42 * known implementations for services inside a container
45 * @return An array containing all the CLASS objects that will be
46 * instantiated in order to get an fully working implementation
50 public Object[] getImplementations() {
51 Object[] res = { DeviceManagerImpl.class };
56 * Function that is called when configuration of the dependencies is
60 * dependency manager Component object, used for configuring the
61 * dependencies exported and imported
63 * Implementation class that is being configured, needed as long
64 * as the same routine can configure multiple implementations
65 * @param containerName
66 * The containerName being configured, this allow also optional
67 * per-container different behavior if needed, usually should not
71 public void configureInstance(Component c, Object imp, String containerName) {
72 if (imp.equals(DeviceManagerImpl.class)) {
74 // XXX - TODO merge with existing APIs
75 Dictionary<String, String> props = new Hashtable<String, String>();
76 props.put("salListenerName", "devicemanager");
79 new String[] { IDeviceService.class.getName(),
80 IfIptoHost.class.getName(),
81 IListenDataPacket.class.getName(),
82 ITopologyManagerAware.class.getName() }, props);
84 c.add(createContainerServiceDependency(containerName)
85 .setService(ISwitchManager.class)
86 .setCallbacks("setSwitchManager", "unsetSwitchManager")
89 c.add(createContainerServiceDependency(containerName)
90 .setService(IDataPacketService.class)
91 .setCallbacks("setDataPacketService",
92 "unsetDataPacketService").setRequired(true));
94 // c.add(createContainerServiceDependency(containerName).setService(
95 // IClusterContainerServices.class).setCallbacks(
96 // "setClusterContainerService",
97 // "unsetClusterContainerService").setRequired(true));
98 c.add(createContainerServiceDependency(containerName)
99 .setService(ITopologyManager.class)
100 .setCallbacks("setTopologyManager", "unsetTopologyManager")
101 .setRequired(false));
103 c.add(createContainerServiceDependency(containerName)
104 .setService(IDataPacketService.class)
105 .setCallbacks("setDataPacketService",
106 "unsetDataPacketService").setRequired(true));
111 * Method which tells how many Global implementations are supported by the
112 * bundle. This way we can tune the number of components created. This
113 * components will be created ONLY at the time of bundle startup and will be
114 * destroyed only at time of bundle destruction, this is the major
115 * difference with the implementation retrieved via getImplementations where
116 * all of them are assumed to be in a container !
119 * @return The list of implementations the bundle will support, in Global
123 protected Object[] getGlobalImplementations() {
128 * Configure the dependency for a given instance Global
131 * Component assigned for this instance, this will be what will
132 * be used for configuration
134 * implementation to be configured
135 * @param containerName
136 * container on which the configuration happens
139 protected void configureGlobalInstance(Component c, Object imp) {