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.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
28 * AffinityManager Bundle Activator
32 public class Activator extends ComponentActivatorAbstractBase {
33 protected static final Logger logger = LoggerFactory
34 .getLogger(Activator.class);
37 * Function called when the activator starts just after some
38 * initializations are done by the
39 * ComponentActivatorAbstractBase.
47 * Function called when the activator stops just before the
48 * cleanup done by ComponentActivatorAbstractBase
51 public void destroy() {
56 * Function that is used to communicate to dependency manager the
57 * list of known implementations for services inside a container
60 * @return An array containing all the CLASS objects that will be
61 * instantiated in order to get an fully working implementation
64 public Object[] getImplementations() {
65 Object[] res = { AffinityManagerImpl.class };
70 * Function that is called when configuration of the dependencies
73 * @param c dependency manager Component object, used for
74 * configuring the dependencies exported and imported
75 * @param imp Implementation class that is being configured,
76 * needed as long as the same routine can configure multiple
78 * @param containerName The containerName being configured, this allow
79 * also optional per-container different behavior if needed, usually
80 * should not be the case though.
82 public void configureInstance(Component c, Object imp, String containerName) {
83 if (imp.equals(AffinityManagerImpl.class)) {
84 Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
85 Set<String> propSet = new HashSet<String>();
86 propSet.add("affinitymanager.configSaveEvent");
87 props.put("cachenames", propSet);
89 c.setInterface(new String[] {
90 IAffinityManager.class.getName(),
91 ICacheUpdateAware.class.getName(),
92 IConfigurationContainerAware.class.getName() }, props);
94 // Now lets add a service dependency to make sure the
95 // provider of service exists
96 c.add(createContainerServiceDependency(containerName).setService(
97 IAffinityManagerAware.class).setCallbacks(
98 "setAffinityManagerAware", "unsetAffinityManagerAware")
100 c.add(createContainerServiceDependency(containerName).setService(
101 IClusterContainerServices.class).setCallbacks(
102 "setClusterContainerService",
103 "unsetClusterContainerService").setRequired(true));
104 c.add(createContainerServiceDependency(containerName).setService(IfIptoHost.class)
105 .setCallbacks("setHostTracker", "unsetHostTracker").setRequired(true));