3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.arphandler.internal;
12 import java.util.Dictionary;
13 import java.util.HashSet;
14 import java.util.Hashtable;
17 import org.apache.felix.dm.Component;
18 import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
19 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
20 import org.opendaylight.controller.connectionmanager.IConnectionManager;
21 import org.opendaylight.controller.hosttracker.IfHostListener;
22 import org.opendaylight.controller.hosttracker.IfIptoHost;
23 import org.opendaylight.controller.hosttracker.hostAware.IHostFinder;
24 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
25 import org.opendaylight.controller.sal.packet.IDataPacketService;
26 import org.opendaylight.controller.sal.packet.IListenDataPacket;
27 import org.opendaylight.controller.switchmanager.ISwitchManager;
28 import org.opendaylight.controller.topologymanager.ITopologyManager;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
32 public class Activator extends ComponentActivatorAbstractBase {
33 protected static final Logger logger = LoggerFactory
34 .getLogger(Activator.class);
38 * Function that is used to communicate to dependency manager the
39 * list of known implementations for services inside a container
42 * @return An array containing all the CLASS objects that will be
43 * instantiated in order to get an fully working implementation
46 public Object[] getImplementations() {
47 Object[] res = { ArpHandler.class };
52 * Function that is called when configuration of the dependencies
55 * @param c dependency manager Component object, used for
56 * configuring the dependencies exported and imported
57 * @param imp Implementation class that is being configured,
58 * needed as long as the same routine can configure multiple
60 * @param containerName The containerName being configured, this allow
61 * also optional per-container different behavior if needed, usually
62 * should not be the case though.
64 public void configureInstance(Component c, Object imp, String containerName) {
65 if (imp.equals(ArpHandler.class)) {
67 Dictionary<String, Object> props = new Hashtable<String, Object>();
68 props.put("salListenerName", "arphandler");
69 Set<String> propSet = new HashSet<String>();
70 propSet.add(ArpHandler.ARP_EVENT_CACHE_NAME);
71 props.put("cachenames", propSet);
73 c.setInterface(new String[] {
74 IHostFinder.class.getName(),
75 IListenDataPacket.class.getName(),
76 ICacheUpdateAware.class.getName()}, props);
78 // We need connection mgr to distribute packet out across the cluster
79 c.add(createServiceDependency().setService(
80 IConnectionManager.class).setCallbacks("setConnectionManager",
81 "unsetConnectionManager").setRequired(true));
84 c.add(createContainerServiceDependency(containerName).setService(
85 ISwitchManager.class).setCallbacks("setSwitchManager",
86 "unsetSwitchManager").setRequired(true));
88 c.add(createContainerServiceDependency(containerName).setService(
89 ITopologyManager.class).setCallbacks("setTopologyManager",
90 "unsetTopologyMananger").setRequired(true));
92 c.add(createContainerServiceDependency(containerName).setService(
93 IDataPacketService.class).setCallbacks(
94 "setDataPacketService", "unsetDataPacketService")
97 c.add(createContainerServiceDependency(containerName).setService(
98 IClusterContainerServices.class).setCallbacks(
99 "setClusterContainerService", "unsetClusterContainerService")
102 // the Host Listener is optional
103 c.add(createContainerServiceDependency(containerName).setService(
104 IfHostListener.class).setCallbacks("setHostListener",
105 "unsetHostListener").setRequired(false));
107 // the IfIptoHost is a required dependency
108 c.add(createContainerServiceDependency(containerName).setService(
109 IfIptoHost.class).setCallbacks("setHostTracker",
110 "unsetHostTracker").setRequired(true));