45414437ccb3d3afe6279fd1d428a8dc930d60fc
[controller.git] / opendaylight / md-sal / zeromq-routingtable / implementation / src / main / java / org / opendaylight / controller / sal / connector / remoterpc / impl / Activator.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.sal.connector.remoterpc.impl;
10
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.RoutingTable;
15 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 import java.util.Dictionary;
20 import java.util.HashSet;
21 import java.util.Hashtable;
22 import java.util.Set;
23
24 /**
25  * @author: syedbahm
26  */
27 public class Activator extends ComponentActivatorAbstractBase {
28
29     protected static final Logger logger = LoggerFactory
30             .getLogger(Activator.class);
31     private static final String CACHE_UPDATE_AWARE_REGISTRY_KEY = "cachenames" ;
32
33
34     /**
35      * Method which tells how many Global implementations are
36      * supported by the bundle. This way we can tune the number of
37      * components created. This components will be created ONLY at the
38      * time of bundle startup and will be destroyed only at time of
39      * bundle destruction, this is the major difference with the
40      * implementation retrieved via getImplementations where all of
41      * them are assumed to be in a container!
42      *
43      *
44      * @return The list of implementations the bundle will support,
45      * in Global version
46      */
47
48     @Override
49     protected Object[] getGlobalImplementations(){
50         logger.debug("Calling getGlobalImplementations to return:", RoutingTableImpl.class);
51         return new Object[] {
52                 RoutingTableImpl.class
53         };
54     }
55
56     /**
57      * Configure the dependency for a given instance Global
58      *
59      * @param c Component assigned for this instance, this will be
60      * what will be used for configuration
61      * @param imp implementation to be configured
62      *
63      */
64     @Override
65     protected void configureGlobalInstance(Component c, Object imp){
66         if (imp.equals(RoutingTableImpl.class)) {
67             Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
68             Set<String> propSet = new HashSet<String>();
69             propSet.add(RoutingTableImpl.ROUTING_TABLE_GLOBAL_CACHE);
70             props.put(CACHE_UPDATE_AWARE_REGISTRY_KEY, propSet);
71
72             c.setInterface(new String[] { RoutingTable.class.getName(),ICacheUpdateAware.class.getName()  }, props);
73             logger.debug("configureGlobalInstance adding dependency:", IClusterGlobalServices.class);
74
75             c.add(createServiceDependency().setService(
76                     IClusterGlobalServices.class).setCallbacks(
77                     "setClusterGlobalServices",
78                     "unsetClusterGlobalServices").setRequired(true));
79
80         }
81     }
82
83
84 }