Merge "Fixed bug when Binding-Aware Data Change Listeners we're not triggered."
[controller.git] / opendaylight / configuration / implementation / src / main / java / org / opendaylight / controller / configuration / internal / Activator.java
index 9fb5b159f64e395249140f3eae4143502665162d..c798eeb05de0883e46aab84bb6d933bd934439fb 100644 (file)
@@ -9,7 +9,14 @@
 
 package org.opendaylight.controller.configuration.internal;
 
+import java.util.Dictionary;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Set;
+
 import org.apache.felix.dm.Component;
+import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
+import org.opendaylight.controller.clustering.services.IClusterContainerServices;
 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
 import org.opendaylight.controller.configuration.IConfigurationAware;
 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
@@ -22,7 +29,7 @@ import org.slf4j.LoggerFactory;
 /**
  * @file Activator.java
  *
- * @brief Component Activator for Configuration Management.
+ * @brief Component Activator for ConfigurationService Management.
  *
  *
  *
@@ -31,22 +38,6 @@ public class Activator extends ComponentActivatorAbstractBase {
     protected static final Logger logger = LoggerFactory
             .getLogger(Activator.class);
 
-    /**
-     * Function called when the activator starts just after some
-     * initializations are done by the
-     * ComponentActivatorAbstractBase.
-     *
-     */
-    public void init() {
-    }
-
-    /**
-     * Function called when the activator stops just before the
-     * cleanup done by ComponentActivatorAbstractBase
-     *
-     */
-    public void destroy() {
-    }
 
     /**
      * Function that is used to communicate to dependency manager the
@@ -57,8 +48,9 @@ public class Activator extends ComponentActivatorAbstractBase {
      * instantiated in order to get an fully working implementation
      * Object
      */
+    @Override
     public Object[] getImplementations() {
-        Object[] res = { ConfigurationContainerImpl.class };
+        Object[] res = { ContainerConfigurationService.class };
         return res;
     }
 
@@ -75,17 +67,26 @@ public class Activator extends ComponentActivatorAbstractBase {
      * also optional per-container different behavior if needed, usually
      * should not be the case though.
      */
+    @Override
     public void configureInstance(Component c, Object imp, String containerName) {
-        if (imp.equals(ConfigurationContainerImpl.class)) {
+        if (imp.equals(ContainerConfigurationService.class)) {
+            Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
+            Set<String> propSet = new HashSet<String>();
+            propSet.add(ContainerConfigurationService.CONTAINER_SAVE_EVENT_CACHE);
+            props.put("cachenames", propSet);
+
             // export the service
-            c.setInterface(new String[] {
-                    IConfigurationContainerService.class.getName(),
-                    IConfigurationAware.class.getName() }, null);
+            c.setInterface(
+                    new String[] { IConfigurationContainerService.class.getName(), IConfigurationAware.class.getName(),
+                            ICacheUpdateAware.class.getName() }, props);
 
             c.add(createContainerServiceDependency(containerName).setService(
                     IConfigurationContainerAware.class).setCallbacks(
-                    "addConfigurationContainerAware",
-                    "removeConfigurationContainerAware").setRequired(false));
+                            "addConfigurationContainerAware",
+                            "removeConfigurationContainerAware").setRequired(false));
+
+            c.add(createContainerServiceDependency(containerName).setService(IClusterContainerServices.class)
+                    .setCallbacks("setClusterServices", "unsetClusterServices").setRequired(true));
         }
     }
 
@@ -102,8 +103,9 @@ public class Activator extends ComponentActivatorAbstractBase {
      * @return The list of implementations the bundle will support,
      * in Global version
      */
+    @Override
     protected Object[] getGlobalImplementations() {
-        Object[] res = { ConfigurationImpl.class };
+        Object[] res = { ConfigurationService.class };
         return res;
     }
 
@@ -115,23 +117,28 @@ public class Activator extends ComponentActivatorAbstractBase {
      * @param imp implementation to be configured
      * @param containerName container on which the configuration happens
      */
+    @Override
     protected void configureGlobalInstance(Component c, Object imp) {
-        if (imp.equals(ConfigurationImpl.class)) {
+        if (imp.equals(ConfigurationService.class)) {
+            Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
+            Set<String> propSet = new HashSet<String>();
+            propSet.add(ConfigurationService.SAVE_EVENT_CACHE);
+            props.put("cachenames", propSet);
 
             // export the service
             c.setInterface(
-                    new String[] { IConfigurationService.class.getName() },
-                    null);
+                    new String[] { IConfigurationService.class.getName(),
+                            ICacheUpdateAware.class.getName() }, props);
 
             c.add(createServiceDependency().setService(
                     IClusterGlobalServices.class).setCallbacks(
-                    "setClusterServices", "unsetClusterServices").setRequired(
-                    true));
+                            "setClusterServices", "unsetClusterServices").setRequired(
+                                    true));
 
             c.add(createServiceDependency().setService(
                     IConfigurationAware.class).setCallbacks(
-                    "addConfigurationAware", "removeConfigurationAware")
-                    .setRequired(false));
+                            "addConfigurationAware", "removeConfigurationAware")
+                            .setRequired(false));
         }
     }
 }