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.controller.forwardingrulesmanager.internal;
12 import java.util.Dictionary;
13 import java.util.HashSet;
14 import java.util.Hashtable;
17 import org.apache.felix.dm.Component;
18 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
19 import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager;
20 import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManagerAware;
21 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
22 import org.opendaylight.controller.sal.core.IContainer;
23 import org.opendaylight.controller.sal.core.IContainerListener;
24 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService;
25 import org.opendaylight.controller.sal.utils.GlobalConstants;
26 import org.opendaylight.controller.switchmanager.IInventoryListener;
27 import org.opendaylight.controller.switchmanager.ISwitchManager;
28 import org.opendaylight.controller.switchmanager.ISwitchManagerAware;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
32 import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
33 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
34 import org.opendaylight.controller.hosttracker.IfIptoHost;
36 public class Activator extends ComponentActivatorAbstractBase {
37 protected static final Logger logger = LoggerFactory
38 .getLogger(Activator.class);
41 * Function called when the activator starts just after some
42 * initializations are done by the
43 * ComponentActivatorAbstractBase.
51 * Function called when the activator stops just before the
52 * cleanup done by ComponentActivatorAbstractBase
55 public void destroy() {
60 * Function that is used to communicate to dependency manager the
61 * list of known implementations for services inside a container
64 * @return An array containing all the CLASS objects that will be
65 * instantiated in order to get an fully working implementation
68 public Object[] getImplementations() {
69 Object[] res = { ForwardingRulesManagerImpl.class };
74 * Function that is called when configuration of the dependencies
77 * @param c dependency manager Component object, used for
78 * configuring the dependencies exported and imported
79 * @param imp Implementation class that is being configured,
80 * needed as long as the same routine can configure multiple
82 * @param containerName The containerName being configured, this allow
83 * also optional per-container different behavior if needed, usually
84 * should not be the case though.
86 public void configureInstance(Component c, Object imp, String containerName) {
87 if (imp.equals(ForwardingRulesManagerImpl.class)) {
88 String interfaces[] = null;
89 Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
90 Set<String> propSet = new HashSet<String>();
91 propSet.add("staticFlows");
92 props.put("cachenames", propSet);
95 if (containerName.equals(GlobalConstants.DEFAULT.toString())) {
96 interfaces = new String[] { IContainerListener.class.getName(),
97 ISwitchManagerAware.class.getName(),
98 IForwardingRulesManager.class.getName(),
99 IInventoryListener.class.getName(),
100 ICacheUpdateAware.class.getName(),
101 IConfigurationContainerAware.class.getName() };
103 interfaces = new String[] {
104 ISwitchManagerAware.class.getName(),
105 IForwardingRulesManager.class.getName(),
106 IInventoryListener.class.getName(),
107 ICacheUpdateAware.class.getName(),
108 IConfigurationContainerAware.class.getName() };
111 c.setInterface(interfaces, props);
113 c.add(createContainerServiceDependency(containerName).setService(
114 IFlowProgrammerService.class).setCallbacks(
115 "setFlowProgrammerService", "unsetFlowProgrammerService")
118 c.add(createContainerServiceDependency(containerName).setService(
119 IClusterContainerServices.class).setCallbacks(
120 "setClusterContainerService",
121 "unsetClusterContainerService").setRequired(true));
122 c.add(createContainerServiceDependency(containerName).setService(
123 ISwitchManager.class).setCallbacks("setSwitchManager",
124 "unsetSwitchManager").setRequired(true));
125 c.add(createContainerServiceDependency(containerName).setService(
126 IForwardingRulesManagerAware.class).setCallbacks(
127 "setFrmAware", "unsetFrmAware").setRequired(false));
128 c.add(createContainerServiceDependency(containerName).setService(
129 IfIptoHost.class).setCallbacks("setHostFinder",
130 "unsetHostFinder").setRequired(true));
131 c.add(createContainerServiceDependency(containerName).setService(
132 IContainer.class).setCallbacks("setIContainer",
133 "unsetIContainer").setRequired(true));