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.HashSet;
13 import java.util.Hashtable;
16 import org.apache.felix.dm.Component;
17 import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
18 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
19 import org.opendaylight.controller.hosttracker.IHostTrackerShell;
20 import org.opendaylight.controller.hosttracker.IfHostListener;
21 import org.opendaylight.controller.hosttracker.IfIptoHost;
22 import org.opendaylight.controller.hosttracker.IfNewHostNotify;
23 import org.opendaylight.controller.hosttracker.hostAware.IHostFinder;
24 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
25 import org.opendaylight.controller.switchmanager.IInventoryListener;
26 import org.opendaylight.controller.switchmanager.ISwitchManager;
27 import org.opendaylight.controller.switchmanager.ISwitchManagerAware;
28 import org.opendaylight.controller.topologymanager.ITopologyManager;
29 import org.opendaylight.controller.topologymanager.ITopologyManagerAware;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
33 public class Activator extends ComponentActivatorAbstractBase {
34 protected static final Logger logger = LoggerFactory
35 .getLogger(Activator.class);
39 * Function that is used to communicate to dependency manager the list of
40 * known implementations for services inside a container
43 * @return An array containing all the CLASS objects that will be
44 * instantiated in order to get an fully working implementation
48 public Object[] getImplementations() {
49 Object[] res = { HostTracker.class };
54 * Function that is called when configuration of the dependencies is
58 * dependency manager Component object, used for configuring the
59 * dependencies exported and imported
61 * Implementation class that is being configured, needed as long
62 * as the same routine can configure multiple implementations
63 * @param containerName
64 * The containerName being configured, this allow also optional
65 * per-container different behavior if needed, usually should not
69 public void configureInstance(Component c, Object imp, String containerName) {
70 if (imp.equals(HostTracker.class)) {
71 Dictionary<String, Object> props = new Hashtable<String, Object>();
72 Set<String> propSet = new HashSet<String>();
73 propSet.add(HostTracker.ACTIVE_HOST_CACHE);
74 props.put("cachenames", propSet);
78 new String[] { ISwitchManagerAware.class.getName(),
79 IInventoryListener.class.getName(),
80 IfIptoHost.class.getName(),
81 IfHostListener.class.getName(),
82 IHostTrackerShell.class.getName(),
83 ITopologyManagerAware.class.getName(),
84 ICacheUpdateAware.class.getName() }, props);
86 c.add(createContainerServiceDependency(containerName)
87 .setService(ISwitchManager.class)
88 .setCallbacks("setSwitchManager", "unsetSwitchManager")
90 c.add(createContainerServiceDependency(containerName)
91 .setService(IClusterContainerServices.class)
92 .setCallbacks("setClusterContainerService",
93 "unsetClusterContainerService").setRequired(true));
94 c.add(createContainerServiceDependency(containerName)
95 .setService(IHostFinder.class)
96 .setCallbacks("setArpHandler", "unsetArpHandler")
98 c.add(createContainerServiceDependency(containerName)
99 .setService(ITopologyManager.class)
100 .setCallbacks("setTopologyManager", "unsetTopologyManager")
101 .setRequired(false));
102 c.add(createContainerServiceDependency(containerName)
103 .setService(IfNewHostNotify.class)
104 .setCallbacks("setnewHostNotify", "unsetnewHostNotify")
105 .setRequired(false));