2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.forwardingrulesmanager.internal;
11 import java.util.Dictionary;
12 import java.util.HashSet;
13 import java.util.Hashtable;
16 import org.apache.felix.dm.Component;
17 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
18 import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager;
19 import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManagerAware;
20 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
21 import org.opendaylight.controller.sal.core.IContainer;
22 import org.opendaylight.controller.sal.core.IContainerListener;
23 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerListener;
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 initializations
42 * are done by the ComponentActivatorAbstractBase.
50 * Function called when the activator stops just before the cleanup done by
51 * ComponentActivatorAbstractBase
54 public void destroy() {
59 * Function that is used to communicate to dependency manager the list of
60 * known implementations for services inside a container
63 * @return An array containing all the CLASS objects that will be
64 * instantiated in order to get an fully working implementation
67 public Object[] getImplementations() {
68 Object[] res = { ForwardingRulesManagerImpl.class };
73 * Function that is called when configuration of the dependencies is
77 * dependency manager Component object, used for configuring the
78 * dependencies exported and imported
80 * Implementation class that is being configured, needed as long
81 * as the same routine can configure multiple implementations
82 * @param containerName
83 * The containerName being configured, this allow also optional
84 * per-container different behavior if needed, usually should not
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)
117 .setService(IFlowProgrammerService.class)
118 .setCallbacks("setFlowProgrammerService",
119 "unsetFlowProgrammerService").setRequired(true));
121 c.add(createContainerServiceDependency(containerName)
122 .setService(IClusterContainerServices.class)
123 .setCallbacks("setClusterContainerService",
124 "unsetClusterContainerService").setRequired(true));
125 c.add(createContainerServiceDependency(containerName)
126 .setService(ISwitchManager.class)
127 .setCallbacks("setSwitchManager", "unsetSwitchManager")
129 c.add(createContainerServiceDependency(containerName)
130 .setService(IForwardingRulesManagerAware.class)
131 .setCallbacks("setFrmAware", "unsetFrmAware")
132 .setRequired(false));
133 c.add(createContainerServiceDependency(containerName)
134 .setService(IfIptoHost.class)
135 .setCallbacks("setHostFinder", "unsetHostFinder")
137 c.add(createContainerServiceDependency(containerName)
138 .setService(IContainer.class)
139 .setCallbacks("setIContainer", "unsetIContainer")