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.Hashtable;
13 import java.util.Dictionary;
14 import org.apache.felix.dm.Component;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 import org.opendaylight.controller.hosttracker.IfHostListener;
19 import org.opendaylight.controller.hosttracker.IfIptoHost;
20 import org.opendaylight.controller.hosttracker.hostAware.IHostFinder;
21 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
22 import org.opendaylight.controller.sal.packet.IListenDataPacket;
23 import org.opendaylight.controller.sal.packet.IDataPacketService;
24 import org.opendaylight.controller.switchmanager.ISwitchManager;
26 public class Activator extends ComponentActivatorAbstractBase {
27 protected static final Logger logger = LoggerFactory
28 .getLogger(Activator.class);
31 * Function called when the activator starts just after some
32 * initializations are done by the
33 * ComponentActivatorAbstractBase.
41 * Function called when the activator stops just before the
42 * cleanup done by ComponentActivatorAbstractBase
45 public void destroy() {
50 * Function that is used to communicate to dependency manager the
51 * list of known implementations for services inside a container
54 * @return An array containing all the CLASS objects that will be
55 * instantiated in order to get an fully working implementation
58 public Object[] getImplementations() {
59 Object[] res = { ArpHandler.class };
64 * Function that is called when configuration of the dependencies
67 * @param c dependency manager Component object, used for
68 * configuring the dependencies exported and imported
69 * @param imp Implementation class that is being configured,
70 * needed as long as the same routine can configure multiple
72 * @param containerName The containerName being configured, this allow
73 * also optional per-container different behavior if needed, usually
74 * should not be the case though.
76 public void configureInstance(Component c, Object imp, String containerName) {
77 if (imp.equals(ArpHandler.class)) {
79 Dictionary<String, String> props = new Hashtable<String, String>();
80 props.put("salListenerName", "arphandler");
81 c.setInterface(new String[] { IHostFinder.class.getName(),
82 IListenDataPacket.class.getName() }, props);
84 c.add(createContainerServiceDependency(containerName).setService(
85 ISwitchManager.class).setCallbacks("setSwitchManager",
86 "unsetSwitchManager").setRequired(true));
88 c.add(createContainerServiceDependency(containerName).setService(
89 IDataPacketService.class).setCallbacks(
90 "setDataPacketService", "unsetDataPacketService")
93 // the Host Listener is optional
94 c.add(createContainerServiceDependency(containerName).setService(
95 IfHostListener.class).setCallbacks("setHostListener",
96 "unsetHostListener").setRequired(false));
98 // the IfIptoHost is a required dependency
99 c.add(createContainerServiceDependency(containerName).setService(
100 IfIptoHost.class).setCallbacks("setHostTracker",
101 "unsetHostTracker").setRequired(true));