2 * Copyright (c) 2013 Plexxi, 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.affinity.affinity.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.hosttracker.IfIptoHost;
21 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
22 import org.opendaylight.affinity.affinity.IAffinityManager;
23 import org.opendaylight.affinity.affinity.IAffinityManagerAware;
24 import org.opendaylight.controller.sal.utils.IObjectReader;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService;
28 import org.opendaylight.controller.switchmanager.ISwitchManager;
31 * AffinityManager Bundle Activator
35 public class Activator extends ComponentActivatorAbstractBase {
36 protected static final Logger logger = LoggerFactory
37 .getLogger(Activator.class);
40 * Function called when the activator starts just after some
41 * initializations are done by the
42 * ComponentActivatorAbstractBase.
50 * Function called when the activator stops just before the
51 * cleanup done by ComponentActivatorAbstractBase
54 public void destroy() {
59 * Function that is used to communicate to dependency manager the
60 * list of 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 = { AffinityManagerImpl.class };
74 * Function that is called when configuration of the dependencies
77 * @param c dependency manager Component object, used for
78 * configuring the dependencies exported and imported
79 * @param imp Implementation class that is being configured,
80 * needed as long as the same routine can configure multiple
82 * @param containerName The containerName being configured, this allow
83 * also optional per-container different behavior if needed, usually
84 * should not be the case though.
87 public void configureInstance(Component c, Object imp, String containerName) {
88 if (imp.equals(AffinityManagerImpl.class)) {
89 Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
90 Set<String> propSet = new HashSet<String>();
91 propSet.add("affinitymanager.configSaveEvent");
92 props.put("cachenames", propSet);
94 c.setInterface(new String[] {
95 IAffinityManager.class.getName(),
96 IConfigurationContainerAware.class.getName(),
97 IObjectReader.class.getName(),
98 ICacheUpdateAware.class.getName() }, props);
100 // Now lets add a service dependency to make sure the
101 // provider of service exists
102 c.add(createContainerServiceDependency(containerName).setService(
103 IAffinityManagerAware.class).setCallbacks(
104 "setAffinityManagerAware", "unsetAffinityManagerAware")
106 c.add(createContainerServiceDependency(containerName).setService(
107 IClusterContainerServices.class).setCallbacks(
108 "setClusterContainerService",
109 "unsetClusterContainerService").setRequired(true));
110 c.add(createContainerServiceDependency(containerName).setService(
111 IFlowProgrammerService.class).setCallbacks(
112 "setFlowProgrammerService", "unsetFlowProgrammerService")
114 c.add(createContainerServiceDependency(containerName).setService(
115 ISwitchManager.class).setCallbacks(
116 "setSwitchManager", "unsetSwitchManager")
118 c.add(createContainerServiceDependency(containerName).setService(IfIptoHost.class)
119 .setCallbacks("setHostTracker", "unsetHostTracker").setRequired(true));
120 logger.debug("Done configuring instance of AffinityImpl class.");