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);
37 * Function called when the activator starts just after some
38 * initializations are done by the
39 * ComponentActivatorAbstractBase.
47 * Function called when the activator stops just before the
48 * cleanup done by ComponentActivatorAbstractBase
51 public void destroy() {
56 * Function that is used to communicate to dependency manager the
57 * list of known implementations for services inside a container
60 * @return An array containing all the CLASS objects that will be
61 * instantiated in order to get an fully working implementation
64 public Object[] getImplementations() {
65 Object[] res = { ArpHandler.class };
70 * Function that is called when configuration of the dependencies
73 * @param c dependency manager Component object, used for
74 * configuring the dependencies exported and imported
75 * @param imp Implementation class that is being configured,
76 * needed as long as the same routine can configure multiple
78 * @param containerName The containerName being configured, this allow
79 * also optional per-container different behavior if needed, usually
80 * should not be the case though.
82 public void configureInstance(Component c, Object imp, String containerName) {
83 if (imp.equals(ArpHandler.class)) {
85 Dictionary<String, Object> props = new Hashtable<String, Object>();
86 props.put("salListenerName", "arphandler");
87 Set<String> propSet = new HashSet<String>();
88 propSet.add(ArpHandler.ARP_EVENT_CACHE_NAME);
89 props.put("cachenames", propSet);
91 c.setInterface(new String[] {
92 IHostFinder.class.getName(),
93 IListenDataPacket.class.getName(),
94 ICacheUpdateAware.class.getName()}, props);
96 // We need connection mgr to distribute packet out across the cluster
97 c.add(createServiceDependency().setService(
98 IConnectionManager.class).setCallbacks("setConnectionManager",
99 "unsetConnectionManager").setRequired(true));
102 c.add(createContainerServiceDependency(containerName).setService(
103 ISwitchManager.class).setCallbacks("setSwitchManager",
104 "unsetSwitchManager").setRequired(true));
106 c.add(createContainerServiceDependency(containerName).setService(
107 ITopologyManager.class).setCallbacks("setTopologyManager",
108 "unsetTopologyMananger").setRequired(true));
110 c.add(createContainerServiceDependency(containerName).setService(
111 IDataPacketService.class).setCallbacks(
112 "setDataPacketService", "unsetDataPacketService")
115 c.add(createContainerServiceDependency(containerName).setService(
116 IClusterContainerServices.class).setCallbacks(
117 "setClusterContainerService", "unsetClusterContainerService")
120 // the Host Listener is optional
121 c.add(createContainerServiceDependency(containerName).setService(
122 IfHostListener.class).setCallbacks("setHostListener",
123 "unsetHostListener").setRequired(false));
125 // the IfIptoHost is a required dependency
126 c.add(createContainerServiceDependency(containerName).setService(
127 IfIptoHost.class).setCallbacks("setHostTracker",
128 "unsetHostTracker").setRequired(true));