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