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.clustering.services.ICacheUpdateAware;
18 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
19 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
20 import org.opendaylight.controller.connectionmanager.IConnectionManager;
21 import org.opendaylight.controller.containermanager.IContainerManager;
22 import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager;
23 import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManagerAware;
24 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
25 import org.opendaylight.controller.sal.core.IContainer;
26 import org.opendaylight.controller.sal.core.IContainerLocalListener;
27 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerListener;
28 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService;
29 import org.opendaylight.controller.sal.utils.GlobalConstants;
30 import org.opendaylight.controller.switchmanager.IInventoryListener;
31 import org.opendaylight.controller.switchmanager.ISwitchManager;
32 import org.opendaylight.controller.switchmanager.ISwitchManagerAware;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
36 public class Activator extends ComponentActivatorAbstractBase {
37 protected static final Logger logger = LoggerFactory.getLogger(Activator.class);
41 * Function that is used to communicate to dependency manager the list of
42 * known implementations for services inside a container
45 * @return An array containing all the CLASS objects that will be
46 * instantiated in order to get an fully working implementation
50 public Object[] getImplementations() {
51 Object[] res = { ForwardingRulesManager.class };
56 * Function that is called when configuration of the dependencies is
60 * dependency manager Component object, used for configuring the
61 * dependencies exported and imported
63 * Implementation class that is being configured, needed as long
64 * as the same routine can configure multiple implementations
65 * @param containerName
66 * The containerName being configured, this allow also optional
67 * per-container different behavior if needed, usually should not
71 public void configureInstance(Component c, Object imp, String containerName) {
72 if (imp.equals(ForwardingRulesManager.class)) {
73 String interfaces[] = null;
74 Dictionary<String, Object> props = new Hashtable<String, Object>();
75 Set<String> propSet = new HashSet<String>();
76 propSet.add(ForwardingRulesManager.WORK_STATUS_CACHE);
77 propSet.add(ForwardingRulesManager.WORK_ORDER_CACHE);
78 propSet.add(ForwardingRulesManager.INSTALLED_SW_VIEW_CACHE);
79 props.put("cachenames", propSet);
82 interfaces = new String[] { IContainerLocalListener.class.getName(), ISwitchManagerAware.class.getName(),
83 IForwardingRulesManager.class.getName(), IInventoryListener.class.getName(),
84 IConfigurationContainerAware.class.getName(), ICacheUpdateAware.class.getName(),
85 IFlowProgrammerListener.class.getName() };
87 c.setInterface(interfaces, props);
89 c.add(createContainerServiceDependency(containerName).setService(IFlowProgrammerService.class)
90 .setCallbacks("setFlowProgrammerService", "unsetFlowProgrammerService").setRequired(true));
91 c.add(createContainerServiceDependency(containerName).setService(IClusterContainerServices.class)
92 .setCallbacks("setClusterContainerService", "unsetClusterContainerService").setRequired(true));
93 c.add(createContainerServiceDependency(containerName).setService(ISwitchManager.class)
94 .setCallbacks("setSwitchManager", "unsetSwitchManager").setRequired(true));
95 c.add(createContainerServiceDependency(containerName).setService(IForwardingRulesManagerAware.class)
96 .setCallbacks("setFrmAware", "unsetFrmAware").setRequired(false));
97 c.add(createContainerServiceDependency(containerName).setService(IContainer.class)
98 .setCallbacks("setIContainer", "unsetIContainer").setRequired(true));
99 c.add(createServiceDependency().setService(IConnectionManager.class)
100 .setCallbacks("setIConnectionManager", "unsetIConnectionManager").setRequired(true));
101 if (GlobalConstants.DEFAULT.toString().equals(containerName)) {
102 c.add(createServiceDependency().setService(IContainerManager.class)
103 .setCallbacks("setIContainerManager", "unsetIContainerManager").setRequired(true));
109 protected Object[] getGlobalImplementations() {
110 final Object[] res = { ForwardingRulesManagerCLI.class };