Add filtering capability to config.ini in order to reference logging bridge version.
[controller.git] / opendaylight / 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.sal.routing.IRouting;
28 import org.opendaylight.controller.switchmanager.ISwitchManager;
29 import org.opendaylight.controller.topologymanager.ITopologyManager;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32
33 public class Activator extends ComponentActivatorAbstractBase {
34     protected static final Logger logger = LoggerFactory
35             .getLogger(Activator.class);
36
37
38     /**
39      * Function that is used to communicate to dependency manager the
40      * list of known implementations for services inside a container
41      *
42      *
43      * @return An array containing all the CLASS objects that will be
44      * instantiated in order to get an fully working implementation
45      * Object
46      */
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     public void configureInstance(Component c, Object imp, String containerName) {
66         if (imp.equals(ArpHandler.class)) {
67             // export the service
68             Dictionary<String, Object> props = new Hashtable<String, Object>();
69             props.put("salListenerName", "arphandler");
70             Set<String> propSet = new HashSet<String>();
71             propSet.add(ArpHandler.ARP_EVENT_CACHE_NAME);
72             props.put("cachenames", propSet);
73
74             c.setInterface(new String[] {
75                     IHostFinder.class.getName(),
76                     IListenDataPacket.class.getName(),
77                     ICacheUpdateAware.class.getName()}, props);
78
79             // We need connection mgr to distribute packet out across the cluster
80             c.add(createServiceDependency().setService(
81                     IConnectionManager.class).setCallbacks("setConnectionManager",
82                     "unsetConnectionManager").setRequired(true));
83
84
85             c.add(createContainerServiceDependency(containerName).setService(
86                     ISwitchManager.class).setCallbacks("setSwitchManager",
87                     "unsetSwitchManager").setRequired(true));
88
89             c.add(createContainerServiceDependency(containerName).setService(
90                     ITopologyManager.class).setCallbacks("setTopologyManager",
91                     "unsetTopologyMananger").setRequired(true));
92
93             c.add(createContainerServiceDependency(containerName).setService(
94                     IDataPacketService.class).setCallbacks(
95                     "setDataPacketService", "unsetDataPacketService")
96                     .setRequired(true));
97
98             c.add(createContainerServiceDependency(containerName).setService(
99                    IClusterContainerServices.class).setCallbacks(
100                    "setClusterContainerService", "unsetClusterContainerService")
101                    .setRequired(true));
102
103             c.add(createContainerServiceDependency(containerName).setService(
104                    IRouting.class).setCallbacks("setRouting","unsetRouting")
105                    .setRequired(false));
106
107             // the Host Listener is optional
108             c.add(createContainerServiceDependency(containerName).setService(
109                     IfHostListener.class).setCallbacks("setHostListener",
110                     "unsetHostListener").setRequired(false));
111
112             // the IfIptoHost is a required dependency
113             c.add(createContainerServiceDependency(containerName).setService(
114                     IfIptoHost.class).setCallbacks("setHostTracker",
115                     "unsetHostTracker").setRequired(true));
116         }
117     }
118 }