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 org.opendaylight.controller.clustering.services.ICacheUpdateAware;
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.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.IClusterContainerServices;
33 import org.opendaylight.controller.connectionmanager.IConnectionManager;
35 public class Activator extends ComponentActivatorAbstractBase {
36 protected static final Logger logger = LoggerFactory.getLogger(Activator.class);
39 * Function called when the activator starts just after some initializations
40 * are done by the ComponentActivatorAbstractBase.
49 * Function called when the activator stops just before the cleanup done by
50 * 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
68 public Object[] getImplementations() {
69 Object[] res = { ForwardingRulesManager.class };
74 * Function that is called when configuration of the dependencies is
78 * dependency manager Component object, used for configuring the
79 * dependencies exported and imported
81 * Implementation class that is being configured, needed as long
82 * as the same routine can configure multiple implementations
83 * @param containerName
84 * The containerName being configured, this allow also optional
85 * per-container different behavior if needed, usually should not
89 public void configureInstance(Component c, Object imp, String containerName) {
90 if (imp.equals(ForwardingRulesManager.class)) {
91 String interfaces[] = null;
92 Dictionary<String, Object> props = new Hashtable<String, Object>();
93 Set<String> propSet = new HashSet<String>();
94 propSet.add(ForwardingRulesManager.WORKSTATUSCACHE);
95 propSet.add(ForwardingRulesManager.WORKORDERCACHE);
96 props.put("cachenames", propSet);
99 interfaces = new String[] { IContainerListener.class.getName(), ISwitchManagerAware.class.getName(),
100 IForwardingRulesManager.class.getName(), IInventoryListener.class.getName(),
101 IConfigurationContainerAware.class.getName(), ICacheUpdateAware.class.getName(),
102 IFlowProgrammerListener.class.getName() };
104 c.setInterface(interfaces, props);
106 c.add(createContainerServiceDependency(containerName).setService(IFlowProgrammerService.class)
107 .setCallbacks("setFlowProgrammerService", "unsetFlowProgrammerService").setRequired(true));
108 c.add(createContainerServiceDependency(containerName).setService(IClusterContainerServices.class)
109 .setCallbacks("setClusterContainerService", "unsetClusterContainerService").setRequired(true));
110 c.add(createContainerServiceDependency(containerName).setService(ISwitchManager.class)
111 .setCallbacks("setSwitchManager", "unsetSwitchManager").setRequired(true));
112 c.add(createContainerServiceDependency(containerName).setService(IForwardingRulesManagerAware.class)
113 .setCallbacks("setFrmAware", "unsetFrmAware").setRequired(false));
114 c.add(createContainerServiceDependency(containerName).setService(IContainer.class)
115 .setCallbacks("setIContainer", "unsetIContainer").setRequired(true));
116 c.add(createServiceDependency().setService(IConnectionManager.class)
117 .setCallbacks("setIConnectionManager", "unsetIConnectionManager")