Make sure invokeOperation is set once
[controller.git] / opendaylight / adsal / arphandler / src / main / java / org / opendaylight / controller / arphandler / internal / 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 package org.opendaylight.controller.arphandler.internal;
11
12 import java.util.Dictionary;
13 import java.util.HashSet;
14 import java.util.Hashtable;
15 import java.util.Set;
16
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;
31
32 public class Activator extends ComponentActivatorAbstractBase {
33     protected static final Logger logger = LoggerFactory
34             .getLogger(Activator.class);
35
36
37     /**
38      * Function that is used to communicate to dependency manager the
39      * list of known implementations for services inside a container
40      *
41      *
42      * @return An array containing all the CLASS objects that will be
43      * instantiated in order to get an fully working implementation
44      * Object
45      */
46     @Override
47     public Object[] getImplementations() {
48         Object[] res = { ArpHandler.class };
49         return res;
50     }
51
52     /**
53      * Function that is called when configuration of the dependencies
54      * is required.
55      *
56      * @param c dependency manager Component object, used for
57      * configuring the dependencies exported and imported
58      * @param imp Implementation class that is being configured,
59      * needed as long as the same routine can configure multiple
60      * implementations
61      * @param containerName The containerName being configured, this allow
62      * also optional per-container different behavior if needed, usually
63      * should not be the case though.
64      */
65     @Override
66     public void configureInstance(Component c, Object imp, String containerName) {
67         if (imp.equals(ArpHandler.class)) {
68             // export the service
69             Dictionary<String, Object> props = new Hashtable<String, Object>();
70             props.put("salListenerName", "arphandler");
71             Set<String> propSet = new HashSet<String>();
72             propSet.add(ArpHandler.ARP_EVENT_CACHE_NAME);
73             props.put("cachenames", propSet);
74
75             c.setInterface(new String[] {
76                     IHostFinder.class.getName(),
77                     IListenDataPacket.class.getName(),
78                     ICacheUpdateAware.class.getName()}, props);
79
80             // We need connection mgr to distribute packet out across the cluster
81             c.add(createServiceDependency().setService(
82                     IConnectionManager.class).setCallbacks("setConnectionManager",
83                     "unsetConnectionManager").setRequired(true));
84
85
86             c.add(createContainerServiceDependency(containerName).setService(
87                     ISwitchManager.class).setCallbacks("setSwitchManager",
88                     "unsetSwitchManager").setRequired(true));
89
90             c.add(createContainerServiceDependency(containerName).setService(
91                     ITopologyManager.class).setCallbacks("setTopologyManager",
92                     "unsetTopologyMananger").setRequired(true));
93
94             c.add(createContainerServiceDependency(containerName).setService(
95                     IDataPacketService.class).setCallbacks(
96                     "setDataPacketService", "unsetDataPacketService")
97                     .setRequired(true));
98
99             c.add(createContainerServiceDependency(containerName).setService(
100                    IClusterContainerServices.class).setCallbacks(
101                    "setClusterContainerService", "unsetClusterContainerService")
102                    .setRequired(true));
103
104             // the Host Listener is optional
105             c.add(createContainerServiceDependency(containerName).setService(
106                     IfHostListener.class).setCallbacks("setHostListener",
107                     "unsetHostListener").setRequired(false));
108
109             // the IfIptoHost is a required dependency
110             c.add(createContainerServiceDependency(containerName).setService(
111                     IfIptoHost.class).setCallbacks("setHostTracker",
112                     "unsetHostTracker").setRequired(true));
113         }
114     }
115 }