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.sal.connector.remoterpc.impl;
11 import org.apache.felix.dm.Component;
12 import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
13 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
14 import org.opendaylight.controller.sal.connector.remoterpc.api.RouteChangeListener;
15 import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
16 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 import java.util.Dictionary;
21 import java.util.HashSet;
22 import java.util.Hashtable;
28 public class Activator extends ComponentActivatorAbstractBase {
30 protected static final Logger logger = LoggerFactory
31 .getLogger(Activator.class);
32 private static final String CACHE_UPDATE_AWARE_REGISTRY_KEY = "cachenames" ;
36 * Method which tells how many Global implementations are
37 * supported by the bundle. This way we can tune the number of
38 * components created. This components will be created ONLY at the
39 * time of bundle startup and will be destroyed only at time of
40 * bundle destruction, this is the major difference with the
41 * implementation retrieved via getImplementations where all of
42 * them are assumed to be in a container!
45 * @return The list of implementations the bundle will support,
50 protected Object[] getGlobalImplementations(){
51 logger.debug("Calling getGlobalImplementations to return:", RoutingTableImpl.class);
53 RoutingTableImpl.class
58 * Configure the dependency for a given instance Global
60 * @param c Component assigned for this instance, this will be
61 * what will be used for configuration
62 * @param imp implementation to be configured
66 protected void configureGlobalInstance(Component c, Object imp){
67 if (imp.equals(RoutingTableImpl.class)) {
68 Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
69 Set<String> propSet = new HashSet<String>();
70 propSet.add(RoutingTableImpl.ROUTING_TABLE_GLOBAL_CACHE);
71 props.put(CACHE_UPDATE_AWARE_REGISTRY_KEY, propSet);
73 c.setInterface(new String[] { RoutingTable.class.getName(),ICacheUpdateAware.class.getName() }, props);
74 logger.debug("configureGlobalInstance adding dependency:", IClusterGlobalServices.class);
77 // RouteChangeListener services will be none or many so the
78 // dependency is optional
79 c.add(createServiceDependency()
80 .setService(RouteChangeListener.class)
81 .setCallbacks("setRouteChangeListener", "unsetRouteChangeListener")
84 //dependency is required as it provides us the caching support
85 c.add(createServiceDependency().setService(
86 IClusterGlobalServices.class).setCallbacks(
87 "setClusterGlobalServices",
88 "unsetClusterGlobalServices").setRequired(true));