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