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);
32 protected void init() {
37 protected void destroy() {
42 * Function that is used to communicate to dependency manager the list of
43 * known implementations for services inside a container
46 * @return An array containing all the CLASS objects that will be
47 * instantiated in order to get an fully working implementation
51 public Object[] getImplementations() {
52 Object[] res = { DeviceManagerImpl.class };
57 * Function that is called when configuration of the dependencies is
61 * dependency manager Component object, used for configuring the
62 * dependencies exported and imported
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
72 public void configureInstance(Component c, Object imp, String containerName) {
73 if (imp.equals(DeviceManagerImpl.class)) {
75 // XXX - TODO merge with existing APIs
76 Dictionary<String, String> props = new Hashtable<String, String>();
77 props.put("salListenerName", "devicemanager");
80 new String[] { IDeviceService.class.getName(),
81 IfIptoHost.class.getName(),
82 IListenDataPacket.class.getName(),
83 ITopologyManagerAware.class.getName() }, props);
85 c.add(createContainerServiceDependency(containerName)
86 .setService(ISwitchManager.class)
87 .setCallbacks("setSwitchManager", "unsetSwitchManager")
90 c.add(createContainerServiceDependency(containerName)
91 .setService(IDataPacketService.class)
92 .setCallbacks("setDataPacketService",
93 "unsetDataPacketService").setRequired(true));
95 c.add(createContainerServiceDependency(containerName)
96 .setService(IfNewHostNotify.class)
97 .setCallbacks("setNewHostNotify",
98 "unsetNewHostNotify").setRequired(false));
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));
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 !
120 * @return The list of implementations the bundle will support, in Global
124 protected Object[] getGlobalImplementations() {
129 * Configure the dependency for a given instance Global
132 * Component assigned for this instance, this will be what will
133 * be used for configuration
135 * implementation to be configured
136 * @param containerName
137 * container on which the configuration happens
140 protected void configureGlobalInstance(Component c, Object imp) {