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.affinity.l2agent;
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.sal.core.ComponentActivatorAbstractBase;
19 import org.opendaylight.controller.sal.packet.IListenDataPacket;
20 import org.opendaylight.controller.sal.packet.IDataPacketService;
21 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService;
22 import org.opendaylight.controller.switchmanager.ISwitchManager;
24 public class Activator extends ComponentActivatorAbstractBase {
25 protected static final Logger logger = LoggerFactory
26 .getLogger(Activator.class);
29 * Function called when the activator starts just after some
30 * initializations are done by the
31 * ComponentActivatorAbstractBase.
39 * Function called when the activator stops just before the
40 * cleanup done by ComponentActivatorAbstractBase
43 public void destroy() {
48 * Function that is used to communicate to dependency manager the
49 * list of known implementations for services inside a container
52 * @return An array containing all the CLASS objects that will be
53 * instantiated in order to get an fully working implementation
56 public Object[] getImplementations() {
57 Object[] res = { L2Agent.class };
62 * Function that is called when configuration of the dependencies
65 * @param c dependency manager Component object, used for
66 * configuring the dependencies exported and imported
67 * @param imp Implementation class that is being configured,
68 * needed as long as the same routine can configure multiple
70 * @param containerName The containerName being configured, this allow
71 * also optional per-container different behavior if needed, usually
72 * should not be the case though.
74 public void configureInstance(Component c, Object imp, String containerName) {
75 if (imp.equals(L2Agent.class)) {
76 // export the services
77 Dictionary<String, String> props = new Hashtable<String, String>();
78 props.put("salListenerName", "L2Agent");
79 c.setInterface(new String[] { IListenDataPacket.class.getName(),
80 IfL2Agent.class.getName() }, props);
82 // register dependent modules
83 c.add(createContainerServiceDependency(containerName).setService(
84 ISwitchManager.class).setCallbacks("setSwitchManager",
85 "unsetSwitchManager").setRequired(true));
87 c.add(createContainerServiceDependency(containerName).setService(
88 IDataPacketService.class).setCallbacks(
89 "setDataPacketService", "unsetDataPacketService")
92 c.add(createContainerServiceDependency(containerName).setService(
93 IFlowProgrammerService.class).setCallbacks(
94 "setFlowProgrammerService", "unsetFlowProgrammerService")