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.forwardingrulesmanager.IForwardingRulesManager;
22 import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManagerAware;
23 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
24 import org.opendaylight.controller.sal.core.IContainer;
25 import org.opendaylight.controller.sal.core.IContainerLocalListener;
26 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerListener;
27 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService;
28 import org.opendaylight.controller.switchmanager.IInventoryListener;
29 import org.opendaylight.controller.switchmanager.ISwitchManager;
30 import org.opendaylight.controller.switchmanager.ISwitchManagerAware;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 public class Activator extends ComponentActivatorAbstractBase {
35 protected static final Logger logger = LoggerFactory.getLogger(Activator.class);
39 * Function that is used to communicate to dependency manager the list of
40 * known implementations for services inside a container
43 * @return An array containing all the CLASS objects that will be
44 * instantiated in order to get an fully working implementation
48 public Object[] getImplementations() {
49 Object[] res = { ForwardingRulesManager.class };
54 * Function that is called when configuration of the dependencies is
58 * dependency manager Component object, used for configuring the
59 * dependencies exported and imported
61 * Implementation class that is being configured, needed as long
62 * as the same routine can configure multiple implementations
63 * @param containerName
64 * The containerName being configured, this allow also optional
65 * per-container different behavior if needed, usually should not
69 public void configureInstance(Component c, Object imp, String containerName) {
70 if (imp.equals(ForwardingRulesManager.class)) {
71 String interfaces[] = null;
72 Dictionary<String, Object> props = new Hashtable<String, Object>();
73 Set<String> propSet = new HashSet<String>();
74 propSet.add(ForwardingRulesManager.WORKSTATUSCACHE);
75 propSet.add(ForwardingRulesManager.WORKORDERCACHE);
76 props.put("cachenames", propSet);
79 interfaces = new String[] { IContainerLocalListener.class.getName(), ISwitchManagerAware.class.getName(),
80 IForwardingRulesManager.class.getName(), IInventoryListener.class.getName(),
81 IConfigurationContainerAware.class.getName(), ICacheUpdateAware.class.getName(),
82 IFlowProgrammerListener.class.getName() };
84 c.setInterface(interfaces, props);
86 c.add(createContainerServiceDependency(containerName).setService(IFlowProgrammerService.class)
87 .setCallbacks("setFlowProgrammerService", "unsetFlowProgrammerService").setRequired(true));
88 c.add(createContainerServiceDependency(containerName).setService(IClusterContainerServices.class)
89 .setCallbacks("setClusterContainerService", "unsetClusterContainerService").setRequired(true));
90 c.add(createContainerServiceDependency(containerName).setService(ISwitchManager.class)
91 .setCallbacks("setSwitchManager", "unsetSwitchManager").setRequired(true));
92 c.add(createContainerServiceDependency(containerName).setService(IForwardingRulesManagerAware.class)
93 .setCallbacks("setFrmAware", "unsetFrmAware").setRequired(false));
94 c.add(createContainerServiceDependency(containerName).setService(IContainer.class)
95 .setCallbacks("setIContainer", "unsetIContainer").setRequired(true));
96 c.add(createServiceDependency().setService(IConnectionManager.class)
97 .setCallbacks("setIConnectionManager", "unsetIConnectionManager")