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 /* Network function chaining service. */
11 package org.opendaylight.affinity.nfchainagent;
13 import java.util.Hashtable;
14 import java.util.Dictionary;
15 import org.apache.felix.dm.Component;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
20 import org.opendaylight.controller.sal.packet.IListenDataPacket;
21 import org.opendaylight.controller.sal.packet.IDataPacketService;
22 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService;
23 import org.opendaylight.controller.switchmanager.ISwitchManager;
25 import org.opendaylight.controller.hosttracker.IfIptoHost;
26 import org.opendaylight.affinity.l2agent.IfL2Agent;
27 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService;
28 //import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager;
30 public class Activator extends ComponentActivatorAbstractBase {
31 protected static final Logger logger = LoggerFactory
32 .getLogger(Activator.class);
35 * Function called when the activator starts just after some
36 * initializations are done by the
37 * ComponentActivatorAbstractBase.
45 * Function called when the activator stops just before the
46 * cleanup done by ComponentActivatorAbstractBase
49 public void destroy() {
54 * Function that is used to communicate to dependency manager the
55 * list of known implementations for services inside a container
58 * @return An array containing all the CLASS objects that will be
59 * instantiated in order to get an fully working implementation
62 public Object[] getImplementations() {
63 Object[] res = { NFchainAgent.class };
68 * Function that is called when configuration of the dependencies
71 * @param c dependency manager Component object, used for
72 * configuring the dependencies exported and imported
73 * @param imp Implementation class that is being configured,
74 * needed as long as the same routine can configure multiple
76 * @param containerName The containerName being configured, this allow
77 * also optional per-container different behavior if needed, usually
78 * should not be the case though.
80 public void configureInstance(Component c, Object imp, String containerName) {
81 if (imp.equals(NFchainAgent.class)) {
82 // export the services
83 Dictionary<String, String> props = new Hashtable<String, String>();
84 props.put("salListenerName", "NFchainAgent");
85 c.setInterface(new String[] { NFchainAgent.class.getName() }, props);
87 // register dependent modules
88 c.add(createContainerServiceDependency(containerName)
89 .setService(IfL2Agent.class)
90 .setCallbacks("setL2Agent", "unsetL2Agent")
92 c.add(createContainerServiceDependency(containerName).setService(IfIptoHost.class)
93 .setCallbacks("setHostTracker", "unsetHostTracker").setRequired(true));
95 c.add(createContainerServiceDependency(containerName).setService(
96 ISwitchManager.class).setCallbacks("setSwitchManager",
97 "unsetSwitchManager").setRequired(true));
99 c.add(createContainerServiceDependency(containerName).setService(
100 IFlowProgrammerService.class).setCallbacks(
101 "setFlowProgrammerService", "unsetFlowProgrammerService")