Fixes to make path redirect affinity work using the new nfchainagent service.
[affinity.git] / nfchainagent / src / main / java / org / opendaylight / affinity / nfchainagent / Activator.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
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
8  */
9
10 /* Network function chaining service. */
11 package org.opendaylight.affinity.nfchainagent;
12
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;
18
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;
24
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;
29
30 public class Activator extends ComponentActivatorAbstractBase {
31     protected static final Logger logger = LoggerFactory
32             .getLogger(Activator.class);
33
34     /**
35      * Function called when the activator starts just after some
36      * initializations are done by the
37      * ComponentActivatorAbstractBase.
38      *
39      */
40     public void init() {
41
42     }
43
44     /**
45      * Function called when the activator stops just before the
46      * cleanup done by ComponentActivatorAbstractBase
47      *
48      */
49     public void destroy() {
50
51     }
52
53     /**
54      * Function that is used to communicate to dependency manager the
55      * list of known implementations for services inside a container
56      *
57      *
58      * @return An array containing all the CLASS objects that will be
59      * instantiated in order to get an fully working implementation
60      * Object
61      */
62     public Object[] getImplementations() {
63         Object[] res = { NFchainAgent.class };
64         return res;
65     }
66
67     /**
68      * Function that is called when configuration of the dependencies
69      * is required.
70      *
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
75      * implementations
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.
79      */
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);
86
87             // register dependent modules
88             c.add(createContainerServiceDependency(containerName)
89                   .setService(IfL2Agent.class)
90                   .setCallbacks("setL2Agent", "unsetL2Agent")
91                   .setRequired(true));
92             c.add(createContainerServiceDependency(containerName).setService(IfIptoHost.class)
93                   .setCallbacks("setHostTracker", "unsetHostTracker").setRequired(true));
94
95             c.add(createContainerServiceDependency(containerName).setService(
96                     ISwitchManager.class).setCallbacks("setSwitchManager",
97                     "unsetSwitchManager").setRequired(true));
98
99             c.add(createContainerServiceDependency(containerName).setService(
100                     IFlowProgrammerService.class).setCallbacks(
101                     "setFlowProgrammerService", "unsetFlowProgrammerService")
102                     .setRequired(true));
103         }
104     }
105 }